2024-11-06
git uses sha-hashes as its revision “numbers”. The same sha → the same commit, the same revision, the same codegit every day!If you compare two hashes and first X hex-digits match, how large is the change that the underlying data is different:
| X | p |
|---|---|
| 1 | \(\approx0.06\) |
| 2 | \(\approx0.004\) |
| 4 | \(\approx0.000015\approx10^{-5}\) |
| 7 | \(\approx0.0000000037\approx10^{-9}\) |
| 40 | \(\approx0.00000000000000000000000000000000000000000000000068\approx10^{-48}\) |
(since we skipped this last week)
/
- .vcs/
- commits/
- 1/
- message.txt
- parents.txt (=none)
- diffs/
- raven.txt.patch
- dove.txt.patch
- 2/
- message.txt
- parents.txt (=1)
- diffs/
- raven.txt.patch
- 3/
- message.txt
- parents.txt (=2)
- diffs/
- sparrow.txt.patch
- dove.txt.patch
- branches/
- main.txt (=3)
- tags/
- v1.0.txt (=2)
- HEAD.txt (=3)
- CURRENT_BRANCH.txt (=main)
- dove.txt
- sparrow.txt
- raven.txtExample VCS system (not git) with 3 revisions, and revision 3 checked out.
We discussed the idea of non-text based diffs (e.g. image diffs), but in practice git is text-based.
99% of people use
gitwith normal (text-based) diff tools
git makes sense mostly for text-based formatsYou will likely never need it, but it is possible to use other diff/patch with git. e.g. images, xlsx, csv, pdf, Jupyter Notebook.
Tip
There are always exceptions to this rule, in time you’ll find out what works for you. However have rules within one repo!
The first thing you have to choose when making a new repo in GitHub is whether it’s public or private
If you make something public later, be aware that all history will also become public!
Editing something in the working directory does nothing with git
When you add something to the index, it can be retrieved from the repo if deleted
When something is committed, it can be retrieved from the repo (as long as it’s a parent of some branch)
However remember: the repo is only a local directory; only when you push to someone else (or GitHub), or backup your directory (to external HD / Dropbox / email to yourself).
Really really important stuff need online and offline backups.
It’s a personal preference / agree on rules per project or repo / you will get a feeling for what works for you (for now: often to get experience)
If your code is not ready yet, just make a commit in a branch!
NB: you push to GitHub after every commit!
branches are cheap
NOTE: This is a preview, we will deep-dive into branches soon
main branch (or is not ready)Note: just working in main and not pushing is NOT how to do it (although technically you have a branch now).