检查等效分支会导致出现未跟踪的文件
所以我有 3 个分支:master
、testing
和 dev
。它们都跟踪 remotes/origin
上的相应分支,我的 gitbranch -a
显示以下内容:
dev
master
testing
remotes/origin/master
remotes/origin/testing
remotes/origin/dev
当我发布测试时,我将 dev
合并到 >testing
然后,当我发布应用程序时,我将 testing
合并到 master
中,因此 master
实际上是我的发布分支。
这已经运行良好一段时间了,我遇到了一些问题,不得不对 origin
进行一些强制推送。没什么大不了的,小开发团队等等。最近我发布了一个版本,因此我的所有分支目前都是等效的(master
== testing
== dev
== origin/master
== origin/testing
== origin/dev
)
今天,我和另一位开发人员注意到,当我们进行git checkout master
大量未跟踪/移动/删除/重命名的内容运行 git status 时会显示文件。这很奇怪,因为记住所有分支都指向同一个提交。怎么会发生这种事呢?
修复它的唯一方法是执行诸如 git reset --hard origin/master 之类的操作,然后我可以切换到测试或开发。奇怪的是,当在 testing
和 dev
之间切换时,不会发生这种情况,就在我切换到 master
尝试调试这个时,我做了一个将 origin
全新克隆到新目录中。新鲜结帐和我们结帐有同样的问题。有什么想法吗?
So I have 3 branches: master
, testing
, and dev
. they all track respective branches on remotes/origin
my git branch -a
shows the following:
dev
master
testing
remotes/origin/master
remotes/origin/testing
remotes/origin/dev
When I release to testing I merge dev
into testing
then when I release the application I merge testing
into master
so master
is effectively my release branch.
This has been working well for a while, I've had a few hiccups and had to do a few force pushes to origin
. Not a big deal, small dev team and all. Recently I made a release so all of my branches are currently equivalent (master
== testing
== dev
== origin/master
== origin/testing
== origin/dev
)
Today, another developer and I noticed that when we did a git checkout master
a ton of untracked/moved/deleted/renamed files show up when running git status
. This is weird, because remember all of the branches are pointing to the same commit. How can this happen?
The only way to fix it is to do something like git reset --hard origin/master
then I can switch to testing
or dev
. Weird thing is this doesn't happen when switching between testing
and dev
, just when I switch to master
Trying to debug this, I did a fresh clone of origin
into a new directory. The fresh checkout has the same problem as our checkouts. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更多信息,当我执行
git checkout master
时,它抱怨模糊的引用“master”解决方案:
出于某种原因,我有一个名为
master
的引用在 .git/refs/ 中,它指向一个REALLY旧提交。因此,当我执行 git checkout master 时,它抱怨引用不明确,因为有两个名为 master 的引用:master
code>master
我在.git/refs/master
闲逛,因此模棱两可的 refs 投诉和结账命令似乎给了第二个
master< /code> 偏好。我删除了文件 .git/refs/master ,问题就消失了。
我一定是在克隆过程中做错了什么,因为我再次尝试了它,但它没有给出额外的
master
引用。More info, when I do the
git checkout master
it complains about abiguous ref 'master'SOLUTION:
For some reason I had a ref named
master
in.git/refs/
It pointed to a REALLY old commit. so when I didgit checkout master
it complained about an ambiguous ref because there are two refs named master:master
which tracksorigin/master
master
I had hanging out at.git/refs/master
Hence the ambiguous refs complaint and the checkout command seemed to give the 2nd
master
preference. I deleted the file.git/refs/master
and the issue went away.I must have done something wrong during the clone, because I tried it again and it didn't give the extra
master
ref.