After cloning from remote git repository (at bettercodes) I made some changes, commited and tried to push:
git push origin master
Errors
This happened to me when my git remote (bitbucket.org) changed their IP address. The quick fix was to remove and re-add the remote, then everything worked as expected. If you're not familiar with how to remove and re-add a remote in git, here are the steps:
Copy the SSH git URL of your existing remote. You can print it to the terminal using this command:
git remote -v
which will print out something like this:
origin git@server-address.org:account-name/repo-name.git (fetch)
origin git@server-address.org:account-name/repo-name.git (push)
Remove the remote from your local git repo:
git remote rm origin
Add the remote back to your local repo:
git remote add origin git@server-address.org:account-name/repo-name.git
This is how it works for me.
Even faster alternative:
cat /dev/null > /var/lock/apache2/DAVlock
What worked for me was:
.git/logs/refs/remotes/origin/branch
.git/refs/remotes/origin/branch
git gc --prune=now
Check that you (git process actually) have access to file .git/info/refs
and this file isn't locked by another process.
Running command git update-ref -d refs/heads/origin/branch
fixed it.
Aside from the many answers already supplied to this question, a simple check on the local repo branches that exist in your machine and those that don't in the remote, will help. In which case you don't use the
git prune
command as many have suggested.
Simply delete the local branch
git branch -d <branch name without a remote tracking branch by the same name>
as shown in the attached screenshot using -D to force delete when you are sure that a local branch does not have a remote branch tracked.