简体   繁体   中英

Git double entry for refs/head in git ls-remote

When I run

$ git
ls-remote
git@foo:bar.git

I get

6826f9697d4b887a0eaa1aaf9338dee23569970a    HEAD
90ff949b16803724913bb85a72e57c4e5d4c4625    refs/head/master
6826f9697d4b887a0eaa1aaf9338dee23569970a    refs/heads/master

it looks like that refs/head/master shouldn't be there and it is messing up my deployment with capistrano because it is checking out the first master it finds. How can I check what it contains and delete it?

Yeah, refs/head/master shouldn't be there. It looks like someone accidentally pushed to refs/head/master , when they meant to push to refs/heads/master .

You can pull the content of your screwed up master with something like:

git fetch git@foo:bar.git refs/head/master:broken-master

This will give you a local branch, broken-master , which contains what the incorrect ref on the server contains. Once you've satisfactorily merged anything that might have gotten stuck in there, and are ready to delete it on the server, you can do the following to delete the broken branch on the server.

git push git@foo:bar.git :refs/head/master

Depending on the server settings, you may need to use a -f flag to force the server to delete the branch.

You will probably also want to use git branch -d broken-master to clean up your temporary local branch that you used for inspecting the contents of the screwed up ref, as long as you've merged everything up or decided it's OK to discard.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM