如何仅使用Git管道命令完成以下基本序列?
% git init
% git add this that
% git commit -m 'initial commit'
% vim this
# ... edit this ...
% git add this
% git commit -m 'update this'
Run Code Online (Sandbox Code Playgroud)
请注意,并非所有命令都具有基础"管道"命令,并且通常也会执行更多命令.但是发生的事情基本上是这样的:
git init- .git基本上通过从share/git-core/templates中的模板复制来创建目录.git add file- 主要git-hash-object -t blob -w file是创建blob对象并更新.git/index文件以包含文件(git-update-index).如果涉及树(几乎总是),那么git-write-tree也使用.git commit- 写入提交对象并将其存储git-hash-object.然后更新分支引用git-update-ref.如果你对Git的内部感兴趣,那么我可以推荐Scott Chacon 的Git Internals书.
好的,以下是我正在寻找的或多或少:
% 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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
268 次 |
| 最近记录: |