Git:在refs / heads中没有相应文件的分支 [英] Git: branches without a corresponding file in refs/heads

查看:166
本文介绍了Git:在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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆