Command | New files | Changed files | Deleted files |
snap no: 1 | |||
Alice creates the (empty) file numbers.txt
snap no: 2 | |||
She adds the file to the index …
snap no: 3 | |||
… and commits the addition of the file.
snap no: 4 | .git/COMMIT_EDITMSG .git/logs/HEAD .git/logs/refs/heads/master .git/objects/20/bc1e2d5da43d25aff12bb23d3b5e8e64a6367f [tree].git/objects/b9/a67b17e19af09a9736ebb2227aa8a598f27404 [commit].git/refs/heads/master | ||
Adding some numbers to the file. Note the typo (tow instead of two)
snap no: 5 | |||
snap no: 6 | .git/objects/29/f498e5b014d0a10f4f560e6890b6d270dc7f79 [tree].git/objects/42/c3a08933e3787597db0d5b01ffa380ab4ae844 [commit].git/objects/6e/c618611186ba72e8df3eff23e96ba047d1e901 [blob] | ||
Create a branch to fix the typo:
It creates the two files .git/logs/refs/heads/fixTypoBranch and .git/refs/heads/fixTypoBranch. These files will later be deleted again when the branch will be deleted. snap no: 7 | |||
Show "available" branches
The star indicates the "current" branch snap no: 8 | |||
Change to the newly created branch
The content of .git/HEAD changes from refs/heads/master to refs/heads/fixTypoBranch snap no: 9 | |||
Fix the typo
snap no: 10 | |||
Make sure that the sed command did its job
snap no: 11 | |||
Commit the fix
snap no: 12 | .git/objects/1d/de6893e90b0e9d53b9fd344e4eb2d3a0480c71 [commit].git/objects/a3/715c9d73d9ceccc57b64fbf6a5e510dc47a61a [tree].git/objects/f3/84549cbeb481e437091320de6d1f2e15e11b4a [blob] | .git/COMMIT_EDITMSG .git/index .git/logs/HEAD .git/logs/refs/heads/fixTypoBranch .git/refs/heads/fixTypoBranch | |
Go back to the original master branch. Note, the fix is not yet commited.
The content of .git/HEAD changes back to snap no: 13 | |||
The typo is fixed in the fixTypoBranch. Because it had not been merged into the master branch, the typo is still there:
snap no: 14 | |||
Also, the "Fix typo" commit is not present in the master branch
snap no: 15 | |||
Add a few numbers:
snap no: 16 | |||
Commit the addition of 5 and 6:
snap no: 17 | .git/objects/17/468ca3631f1e67e7a751830273b5665575bd73 [commit].git/objects/3b/828979307eeba5e91e7691cd009bd6865530b9 [blob].git/objects/63/cafdb1712b1b86553f618c1490f2039e2f2274 [tree] | ||
Showing the commit tree:
Read the log from bottom upwards. Asterisks signify commits. snap no: 18 | |||
By switching to the fixTypoBranch-branch, it can be shown that the branches are truly independent from one another.
snap no: 19 | |||
In fixTypoBranch, the numbers 5 and 6 don't exist, but the typo is fixed.
snap no: 20 | |||
Going back to master.
snap no: 21 | |||
Int the master branch, the numbers 5 and 6 exist, but also does the typo:
snap no: 22 | |||
Merge the typo fix from fixTypoBranch
snap no: 23 | .git/ORIG_HEAD .git/objects/b5/660615986901aceae1450e10650892e191f8dc [blob].git/objects/dd/aedce41157e122ba35e9b085b0bd97a3ab586e [tree].git/objects/fc/c8c66bb43fe6cb9d9a5d376f75946895d0fd99 [commit] | ||
Showing the effects of the merge: numbers 5 and 6 exist and the typo has gone.
snap no: 24 | |||
A merge creates a seperate commit object (In this case: fcc8c66…). So (unlike Subversion(?), it needs not be commited).
snap no: 25 | |||
Note: the commit object of a merge has two parents
snap no: 26 | |||
The fixTypoBranch is not needed anymore, we can delete it.
This deletes the two files ./git/logs/refs/heads/fixTypoBranch and ./git/refs/heads/fixTypoBranch that were previously created with the git branch command. Note: the objects of the branch are not deleted. snap no: 27 | |||
The branch is gone.
snap no: 28 |