Git:在refs / heads中没有相应文件的分支 [英] Git: branches without a corresponding file in refs/heads
问题描述
我有一个有很多分支的git仓库: git branch
列出了20多个分支。但 ls .git / refs / heads
只列出其中的4个。为了研究这个问题,我在一个空目录中创建了一个测试存储库,添加了一个文件,提交了更改并创建了一个新的分支
code>侧。现在 git branch
给我
$ $ $ $ $ $ $
和 ls .git / refs / heads
给出
主方
然而,在 git gc
之后, .git / refs / heads
中的文件消失了,但 git branch
仍然显示我两个分支。 git从哪里获取这些信息?
您的参考文献因性能原因而被打包,现在可以在.git / packed-refs cat .git / packed-refs
。这个手册页做了很好的解释 https://www.kernel.org/pub/software/scm/git/docs/git-pack-refs.html 。
I have a git repository with lots of branches: git branch
lists more than 20 branches. But ls .git/refs/heads
lists only 4 of them. How can that be?
To investigate the issue a bit, I created a test repository in an empty directory, added one file, commited the change and created a new branch side
. Now git branch
gives me
* master
side
and ls .git/refs/heads
gives
master side
However, after a git gc
, the files in .git/refs/heads
disappear, but git branch
still shows me both branches. Where does git get this information from?
Your refs are getting packed for performance reasons they can now be found in .git/packed-refs cat .git/packed-refs
. This man page does a pretty good job of explaining it https://www.kernel.org/pub/software/scm/git/docs/git-pack-refs.html.
这篇关于Git:在refs / heads中没有相应文件的分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!