Git problems with git push --all

萝らか妹 提交于 2019-12-18 14:53:38

问题


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

回答1:


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



回答2:


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.




回答3:


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.




回答4:


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.



来源:https://stackoverflow.com/questions/4001847/git-problems-with-git-push-all

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!