Basic git without china?

How to execute the following basic sequence 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' 
+4
source share
2 answers

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 
+5
source

Please note that not all teams have basic plumbing commands, and often do more than them. But here is what essentially happens:

  • git init - Creates a .git directory, essentially by copying from a template to share / git -core / templates.
  • git add file - Basically git-hash-object -t blob -w file , which creates a blob object and updates the .git/index file to include the file ( git-update-index ). If a tree is involved (almost always), then git-write-tree .
  • git commit - Writes a commit object and saves it using git-hash-object . Then the ref link is updated with git-update-ref .

If you are interested in the internal elements of Git, I can recommend Scott Chacon's Git Internals book.

+9
source

Source: https://habr.com/ru/post/1482738/


All Articles