git - 理解 git rev-list

标签 git git-rev-list

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

    相关文章:

    git - 什么管道命令提供与 git log --follow 相同的功能?

    git - 如何列出数据库中的所有 git 对象?

    Git:如何在 Windows 上发出 rev-list --stdin 输入的结束信号

    ruby - 如何在我的 git hook 目录之外进行 cd

    git - GIT 是否基于日期时间 merge ?

    git - 修复 git 中的两个 bug 的正常流程是什么?

    git - 列出master后面的所有远程分支

    c# - 找不到文件 : Source link authentication failed

    php - 我应该为每个项目下载 Laravel 吗?

    git - 获取 2 个指定提交哈希值之间的提交哈希值