git 303
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo “foo” > example.txt | |
### add to .git/objects | |
git hash-object -w example.txt | |
git cat-file -p <blob-hash> | |
find .git/objects -type f | |
### add file to .git/index (“stage”) | |
git update-index ---add --cacheinfo 100644 <blob-hash> example.txt | |
### create tree node (from staged index) | |
git write-tree | |
git cat-file -p <tree-hash> | |
### add commit | |
echo "add example" | git commit-tree <tree-hash> | |
git cat-file -p <commit-hash> | |
### change a file | |
echo "baz" >> example.txt | |
git update-index example.txt | |
git write-tree | |
echo "update example" | git commit-tree <commit-hash-2> -p <commit-hash (von oben)> | |
#### git log doesn't show the new commits?!?!? | |
### `master` needs to be linked to the desired commit: | |
echo <commit-hash> > .git/refs/heads/master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From: https://medium.com/@shalithasuranga/how-does-git-work-internally-7c36dcb1f2cf