How would the following basic sequence be done using only Git plumbing commands?
% git init
% git add this that
% git commit -m 'initial commit'
% vim this
# ... edit this ...
% git add this
% git commit -m 'update this'
Note that not all commands have underlying “plumbing” commands and also often do more than them. But what’s going on is essentially this:
git init
– Creates a .git
directory essentially by copying from the template in share/git-core/templates.git add file
– Is mostly git-hash-object -t blob -w file
which creates the blob object and updates the .git/index
file to include the file (git-update-index
). If a tree is involved (nearly always), then git-write-tree
is also used.git commit
– Writes the commit object and stores it with git-hash-object
. Then the branch ref is updated with git-update-ref
.If you are interested in the internals of Git, then I can recommend the Git Internals book by Scott Chacon.
OK, the following is more or less what I was looking for:
% git init
% git hash-object -w this
24ac30b4e2ec3847ed909d7772b1639fb4ce9dc0
% git update-index --add --cacheinfo 100644 \
24ac30b4e2ec3847ed909d7772b1639fb4ce9dc0 this
% git hash-object -w that
aca9f36014c1e5e5f142b81ddc3e1339d39cafa7
% git update-index --add --cacheinfo 100644 \
aca9f36014c1e5e5f142b81ddc3e1339d39cafa7 that
% git write-tree
2f7f75f1d091c19c6d857309d4c6428a1daa9aae
% git commit-tree -m 'initial commit' 2f7f75f
ed92b7cf869f580904a6065166c823712a459b4a
% git update-ref refs/heads/master ed92b7c
% vim this
# ... edit this ...
% git hash-object -w this
34ff55620a76bfd6e76f442f77464174f0a0959f
% git update-index --cacheinfo 100644 \
34ff55620a76bfd6e76f442f77464174f0a0959f this
% git write-tree
1e615b69c3b6959297cfaac6f139626ea4e54e7e
% git commit-tree -m 'update this' 1e615b6
d9478d161498357c2c3dd975f76bc2fbc817695c
% git update-ref refs/heads/master d9478d1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With