如果在以后的某个日期从同一存储库的任何分支执行,输出的输出是否git rev-list --all --count会下降?
(我想将其用作将在所有分支中单调增加的内部版本号。)
它是根据一定的条件下,你可以简单地避免可能的:
--all在refs/(另请参见git for-each-ref)中找到每个引用,以将起点作为提交DAG的起点git rev-list 然后将每个提交对象跟随其所有父对象,一直返回到根提交--count打印不带会打印的提交次数--count。This means the question is equivalent to ‘how could one reduce the number of commits visited in this tree traversal?’ and the answer to that is to remove commits from the repository, or even just remove some references that make some of those commits reachable.
For instance, we can start by creating a "raise the count" reference; let's make it a branch to make subsequently raising the count easy as well:
$ git checkout -b raise-the-count
Run Code Online (Sandbox Code Playgroud)
Now let's add a bunch of commits:
$ for i in $(jot 10); do git commit -m "dummy commit $i" --allow-empty; done
Run Code Online (Sandbox Code Playgroud)
The --count we get now, with this raise-the-count branch present, is 10 higher than it was before. Now we delete the branch label:
$ git checkout master; git branch -D raise-the-count
Run Code Online (Sandbox Code Playgroud)
and the --count we get drops back those same 10 commits.
删除提交非常困难(相当于在删除的提交之后“替换所有提交;这与删除敏感文件是相同的问题;虽然git filter-branch可以让您做到,但很痛苦”)但是删除了一个分支-可以在一段时间内恢复reflogs-不是很困难,最终仅在该分支上的提交将被垃圾收集。
相同的规则适用于所有其他引用(主要是标记和“注释”),因此,如果您对自己强加“从不删除任何内容”的规则,并坚持下去,您将获得不减少的--count。
| 归档时间: |
|
| 查看次数: |
616 次 |
| 最近记录: |