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 a开发者_如何转开发nd 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?
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 did git checkout master
it complained about an ambiguous ref because there are two refs named master:
- The local tracking branch
master
which tracksorigin/master
- This weird ref
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.
精彩评论