Warning: duplicate ref when git is pressed

when click the leading branch to the remote target: tmp

git push tmp master 

I get this message

 warning: Duplicated ref: refs/heads/master 

push can still be successful.

but what does it mean? How can I find more information about the magazine?

this is my .git / config

 [core] repositoryformatversion = 0 filemode = false bare = false logallrefupdates = true symlinks = false ignorecase = true hideDotFiles = dotGitOnly [remote "origin"] fetch = +refs/heads/*:refs/remotes/origin/* url = git@github.com :testuser/myproject.git [branch "master"] remote = origin merge = refs/heads/master [remote "tmp"] url = git@192.168.1.44 :testuser/myproject.git fetch = +refs/heads/*:refs/remotes/tmp/* 

and my git version is 1.7.11.msysgit.1


show-ref and ls-remote info

 $ git show-ref 1696d17186db41cc70876f76f943e18ea4708ad3 refs/heads/master 3c51688bf27e712001db1b6e9f316748634643c4 refs/remotes/origin/HEAD 3c51688bf27e712001db1b6e9f316748634643c4 refs/remotes/origin/master 1696d17186db41cc70876f76f943e18ea4708ad3 refs/remotes/tmp/master $ git ls-remote tmp warning: Duplicated ref: refs/heads/master 1696d17186db41cc70876f76f943e18ea4708ad3 HEAD 1696d17186db41cc70876f76f943e18ea4708ad3 refs/heads/master $ git ls-remote origin 3c51688bf27e712001db1b6e9f316748634643c4 HEAD 3c51688bf27e712001db1b6e9f316748634643c4 refs/heads/master 

git show-ref output to tmp

 $ git show-ref warning: Duplicated ref: refs/heads/master 1696d17186db41cc70876f76f943e18ea4708ad3 refs/heads/master 

contents of packed-refs on tmp

 # pack-refs with: peeled 3c51688bf27e712001db1b6e9f316748634643c4 refs/heads/master 3c51688bf27e712001db1b6e9f316748634643c4 refs/heads/master 

find . output find . as an open repo myproject.git . there are too many subtypes in the objects folder, so I don’t paste them.

 $ find . . ./branches ./packed-refs ./objects ./HEAD ./info ./info/exclude ./config ./description ./refs ./refs/tags ./refs/heads ./refs/heads/master ./hooks ./hooks/commit-msg.sample ./hooks/update.sample ./hooks/pre-commit.sample ./hooks/prepare-commit-msg.sample ./hooks/post-update.sample ./hooks/pre-rebase.sample ./hooks/post-receive ./hooks/pre-applypatch.sample ./hooks/update ./hooks/applypatch-msg.sample 
+4
source share
1 answer

IIRC, this means that you somehow finished creating another ref that has the name master, but does not live in the usual place. Several times I saw this because I was busy with the plumber team and did not provide the full path to ref ( refs/heads/master ) when the team was waiting. First, let your local repository be updated using the remote with:

 git fetch --all 

First check the local repository:

 git show-ref | grep -i master 

-i is there because you are on Windows, and case sensitivity can be a problem. I suspect you might see something like refs/master in the list. The idea is that there is a name that can be solved in two ways. refs/remotes/origin/master and refs/remotes/tmp/master are fine, as they are correctly replaced with names.

If all else fails, check the remote:

 git ls-remote url://to/remote/repo.git | grep master 

I suspect the problem is in your local repository. For a local repository, you can remove ref via update-ref :

 git update-ref -m 'remove duplicate ref' -d <duplicate ref> 

Where <duplicate ref> is optional, found in the show-ref command. Branches are stored in refs/heads . Be careful not to delete refs/heads/master .

If on the remote control you must delete the duplicate using:

 git push origin :<duplicate ref> 

Where <duplicate ref> is optional, found by the ls-remote above. Again, be careful. Do not use master or refs/heads/master .

If possible, update your question with the output of git show-ref and git ls-remote . In addition, I can skip you in the comments to make sure that you do not lose any data.

Now when we see that packaged refs is the culprit

So the problem is that packed-refs has more than one line referring to master. I'm not quite sure how this will turn out, but I suspect there is a version of git that allowed it to slip through. A git gc will overwrite packed-refs , so I'll just do it on your tmp remote.

+5
source

All Articles