标签云

微信群

扫码加入我们

WeChat QR Code

I have a base repository that lives on a UNC \machine\share ....etc. I have a local clone that I work on in the master branch and occasionally merge over to the "stable" branch.

usually I do a git push --all

to move all changes in all branches up to the server. After creating a new branch git branch MultiCompany

and then pushing it to the server git push --all

which creates the branch on the server also. I did some work, committed all the changes in multicompany branch and then tried to do a git push --all

and got the following error:

cdturner@OAHU ~/desktop/git sourcetree/maerekai.web.framework (multicompany) 
$ git push --all
Counting objects: 28, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (22/22), done.
Writing objects: 100% (23/23), 11.34 KiB, done.
Total 23 (delta 8), reused 0 (delta 0)
Unpacking objects: 100% (23/23), done.
error: Ref refs/heads/multicompany is at bd5a32df35ce8d5ae30ce999af34c4c5f35581df but expected 0000000000000000000000000000000000000000
remote: error: failed to lock refs/heads/multicompany
To //pluto/users/cdturner/Git repositories/Maerekai.web.framework.git
 ! [remote rejected] multicompany -> multicompany (failed to lock)
error: failed to push some refs to '//pluto/users/cdturner/Git repositories/Maerekai.web.framework.git'

I tried to back out the last commit withgit reset --hard HEAD^

and then retried the push.....

cdturner@OAHU ~/desktop/git sourcetree/maerekai.web.framework (multicompany)
$ git push --all
Total 0 (delta 0), reused 0 (delta 0)
error: Ref refs/heads/multicompany is at bd5a32df35ce8d5ae30ce999af34c4c5f35581df but expected 0000000000000000000000000000000000000000
remote: error: failed to lock refs/heads/multicompany
To //pluto/users/cdturner/Git repositories/Maerekai.web.framework.git
 ! [remote rejected] multicompany -> multicompany (failed to lock)
error: failed to push some refs to '//pluto/users/cdturner/Git repositories/Maerekai.web.framework.git'`


Thank you! Same problem here... thanks to you comment I will finnaly be able to fix the problem I got here :)

2018年08月16日27分21秒

I wasn't able to rename using SourceTree ("branch already exists...)", so I renamed to a temporary branch name, deleted from .git/refs/heads the folder having the incorrect capitalization, and then renamed the branch back to use the correct capitalization.

2018年08月16日27分21秒

When I tried this I got the error message "fatal: A branch named already exists." So I used the "-M" switch instead.

2018年08月16日27分21秒

This was the solution for me. I was trying to push dev when an ancient branch called dev/rob existed on the remote. Running git push origin :dev/rob first fixed it.

2018年08月16日27分21秒

Worked for me too. Was trying to push a branch called release/patch1 when a branch named release already existed on the remote.

2018年08月15日27分21秒

Git disallows having a branch, a branch folder, and a tag with the same name. TIL

2018年08月15日27分21秒

So git gc it is :)

2018年08月15日27分21秒