Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git problems with git push --all

Tags:

git

push

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'`
like image 919
Chris Turner Avatar asked Oct 23 '10 00:10

Chris Turner


People also ask

Why is git push failing?

This error mainly occurs when you attempt to push your local changes to GitHub while the local repository (repo) has not yet been updated with any changes made in the remote repo. So Git is trying to tell you to update the local repo with the current changes in the remote before pushing your own changes.

What does -- all do in git push?

Push to a Specific Remote Repository and All Branches in it in which: --all is the flag that signals that you want to push all branches to the remote repository. REMOTE-NAME is the name of the remote repository you want to push to.

Will git push push all commits?

git push uploads all local branch commits to the corresponding remote branch.

What are the issues when a git push doesn't work?

You need to use git pull and resolve the difference between your local changes and the remote changes before you can git push . There is still a commit in the remote branch initializing the repo that may not be in your local version. I'd still recommend pulling the remote.


2 Answers

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
like image 155
A.L. Avatar answered Oct 15 '22 16:10

A.L.


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.

like image 38
Adam Dymitruk Avatar answered Oct 15 '22 16:10

Adam Dymitruk