gpt4 book ai didi

git - 理解 git rev-list

转载 作者:行者123 更新时间:2023-12-04 12:14:02 28 4
gpt4 key购买 nike

在寻找 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/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com