Git problems with git push
I have a base repository that lives on a UNC machineshare ....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 with git 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'`
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
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.
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.
下一篇: 使用git push的Git问题