在寻找 git hook 示例时,我遇到了以下帖子:https://github.com/Movidone/git-hooks/blob/master/pre-receive我想了解以下命令:
git rev-list $new_list --not --all
从哪里获得 new_list:NULL_SHA1="0000000000000000000000000000000000000000" # 40 0's
new_list=
any_deleted=false
while read oldsha newsha refname; do
case $oldsha,$newsha in
*,$NULL_SHA1) # it's a delete
any_deleted=true;;
$NULL_SHA1,*) # it's a create
new_list="$new_list $newsha";;
*,*) # it's an update
new_list="$new_list $newsha";;
esac
done
我认为 rev-list 以相反的时间顺序显示提交。但是,有人可以分享更多关于
-not
的见解吗?和 -all
选项是用来做什么的?根据文档:
--not
Reverses the meaning of the ^ prefix (or lack thereof) for all following revision specifiers, up to the next --not.
--all
Pretend as if all the refs in refs/ are listed on the command line as <commit>.
我无法完全理解这些选项。[更新]
在做了一些测试提交之后,我想如果我不使用
--not
和 --all
然后选项,git rev-list
列出分支上的所有提交,而不是我打算推送的提交。但是,想了解为什么在
--all
时不在终端上打印 sha 值。选项通过了吗?
最佳答案
它的意思是:
$new_list
,新的、修改的或删除的提交 ^
给出的提交中可访问的提交在他们前面,这里是“all”,即所有的HEADS commit,或者tagged commit。 这将 rev-list 限制为仅接收到的新提交,而不是所有提交(已接收并已存在于接收存储库中)
关于git - 理解 git rev-list,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64397278/