Command | New files | Changed files | Deleted files |
snap no: 1 | |||
Alice creates a file to store numbers …
snap no: 2 | |||
… adds it to the repository …
snap no: 3 | |||
… and commits it.
snap no: 4 | .git/COMMIT_EDITMSG .git/logs/HEAD .git/logs/refs/heads/master .git/objects/80/e376080b1b1616daef27f1136347d377941fda [commit].git/objects/c8/52b721ba9dc9f99dd740246d787dd804a8e275 [tree].git/refs/heads/master | ||
Unfortunately, Alice has made a few typos (tow instead of two, fife instead of five and eigth instead of eight)
snap no: 5 | |||
So, she creates a new branch to start fixing the typos
snap no: 6 | |||
Fix the first typo:
snap no: 7 | |||
Commit the fix:
snap no: 8 | .git/objects/7f/b247e1c71f558f5c4ad9e53abb4eb98681bdd0 [blob].git/objects/e0/cea2c02ba508822c4f87af2084702a23198046 [commit].git/objects/ea/636a46f088b7ede4dfdb7f42cb670ff4b535a0 [tree] | ||
Immediately, Alice starts to fix the second typo:
snap no: 9 | |||
In the mean time, Bob clones Alice's repository.
After cloning, he has received all objects that already are in Alice's repository. snap no: 1 | .git/packed-refs .git/index .git/HEAD .git/config .git/objects/4b/ac4b3e82a21e3bcbad355641126d833be1c192 [blob].git/objects/7f/b247e1c71f558f5c4ad9e53abb4eb98681bdd0 [blob].git/objects/80/e376080b1b1616daef27f1136347d377941fda [commit].git/objects/c8/52b721ba9dc9f99dd740246d787dd804a8e275 [tree].git/objects/ea/636a46f088b7ede4dfdb7f42cb670ff4b535a0 [tree].git/objects/e0/cea2c02ba508822c4f87af2084702a23198046 [commit].git/refs/heads/fixTypo .git/refs/remotes/origin/HEAD .git/logs/HEAD .git/logs/refs/heads/fixTypo .git/logs/refs/remotes/origin/HEAD numbers.txt | ||
Bob wants to inquire about available branches:
A little surprising, there is only the fixTypo branch and no master branch. This is (probably?) because he cloned from Alice's repository when it was in the fixTypo branch. snap no: 2 | |||
So, in order to see the remote tracking branches, he uses the
snap no: 3 | |||
With the
snap no: 4 | |||
Examine the content of numbers.txt
Bob sees the commited fix (two instead of tow) of Alice at the time of his cloning the repository. snap no: 5 | |||
Bob wants to work on the master branch. Therefore, he creates it like so …
snap no: 6 | .git/config | ||
… and switches to it:
Note: Bob could have done the creation and switch to the new branch in one step: snap no: 7 | |||
The content of numbers.txt now has all three typos:
snap no: 8 | |||
In the mean time, Alice commits her second typo fix.
snap no: 10 | .git/objects/64/516406f1da1f62195e0eb8a7d26b3a8bbf1940 [tree].git/objects/b8/0b8495d92c247d359aa89393613d1801bf3a94 [blob].git/objects/cc/7b5b38a516ea85f4711d1d28fa9eba5bea62d4 [commit] | ||
Bob, being on the master branch, adds 11 and 12 to numbers.txt:
snap no: 9 | |||
Commit the changes:
snap no: 10 | .git/COMMIT_EDITMSG .git/objects/80/dbdd25a98f40c3a2f97a6acb91611b6ddf8fca [blob].git/objects/d8/cff160dc1e90be3685fe37f8c1d1a5641d701c [tree].git/objects/f6/ef2aa6d07bcfa82c7d72a2551c378c014c8cb1 [commit] | ||
snap no: 11 | |||
Bob's push also changes Alice's repository snap no: 11 | .git/objects/80/dbdd25a98f40c3a2f97a6acb91611b6ddf8fca [blob].git/objects/d8/cff160dc1e90be3685fe37f8c1d1a5641d701c [tree].git/objects/f6/ef2aa6d07bcfa82c7d72a2551c378c014c8cb1 [commit] | ||
He now pulls from Alice's repository:
Note: it pulls the commit object of Alice's latest typo fix, but it does not update snap no: 12 | .git/FETCH_HEAD .git/ORIG_HEAD .git/logs/refs/remotes/origin/fixTypo .git/objects/64/516406f1da1f62195e0eb8a7d26b3a8bbf1940 [tree].git/objects/b8/0b8495d92c247d359aa89393613d1801bf3a94 [blob].git/objects/cc/7b5b38a516ea85f4711d1d28fa9eba5bea62d4 [commit].git/refs/remotes/origin/fixTypo | ||
Bob checks out the fixTypo branch.
He would be mistaken if he believed that he now has Alice's latest fix. Note git's warning Your branch is behind 'origin/fixTypo' by 1 commit… snap no: 13 | |||
Bob does not according to git's recommendation to execute
… so he still sees fife instead of the corrected five. snap no: 14 | |||
He now does execute
… which updates snap no: 15 | .git/FETCH_HEAD .git/ORIG_HEAD .git/index .git/logs/HEAD .git/logs/refs/heads/fixTypo .git/refs/heads/fixTypo numbers.txt | ||
Showing the content of the file:
This time, the file does contain Alice's correction. snap no: 16 | |||
In the mean time, Alice checks out the master branch.
Note, git does not say anything about the branch being behind. snap no: 12 | |||
So, she sees Bob's addition of eleven and twelve.
snap no: 13 |