Git problems with git push --all

2019-02-08 11:46发布

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'`

标签: git push
4条回答
孤傲高冷的网名
2楼-- · 2019-02-08 12:14

An error I found was trying to push a branch develop to a repository that had branches named: develop/1148 and develop/693. git isn't ok with this (I forget why), so deleting those branches (if possible) fixed this hangup.

查看更多
趁早两清
3楼-- · 2019-02-08 12:22

For the record, I believe the root cause of this problem was the difference in capitalisation between the local and remote branch names, and the case-insensitive nature of the Windows share that hosted the remote repository.

We just encountered this exact same error and were able to resolve the problem simply by renaming the local branch to match the capitalisation of the existing remote branch.

See here how to rename a local branch.

In Windows, due to capitalization, you may need to take two steps:

git branch -m example foo
git branch -m foo EXAMPLE
查看更多
我欲成王,谁敢阻挡
4楼-- · 2019-02-08 12:28

do a git fsck --full on the remote repo. The remote repo may have become corrupt. Clone another one from the remote. Replace the original remote with this one. You should now be able to push again. Something has happened to the remote repo. Nothing you're doing is out of line with regular use.

查看更多
姐就是有狂的资本
5楼-- · 2019-02-08 12:31

Thanks, git fsck --full reported "dangling commit"

so git prune blew away the offending stuff and I got to type it in again. Btu at least the trees are all resolved..

Thanks for the help.

查看更多
登录 后发表回答