After cloning from remote git repository (at bettercodes) I made some changes, commited and tried to push:
git push origin master
Errors
In my case I had to manually delete old tags which had been removed on remote.
Run git fetch --all
before git pull
. That should solve the problem.
I had this problem, when I was trying to create a new feature branch that contained name of the old branch, e.g. origin - branch1 and I wanted to create branch1-feature. It wasn't possibble, but branch1/feature was already.
I fixed this by doing the following
git branch --unset-upstream
rm .git/refs/remotes/origin/{branch}
git gc --prune=now
git branch --set-upstream-to=origin/{branch} {branch}
#or git push --set-upstream origin {branch}
git pull
This assuming that your local and remote branches are aligned and you are just getting the refs error as non fatal.
I had this issue because I was on a branch that had a similar name to an upstream branch. i.e. the upstream branch was called example-branch
and my local branch was called example-branch/backend
. The solution was changing the name of my local branch like so:
git branch -m <new name goes here>
This sounds like a permissions issue - is it possible you had two windows open, executing with separate rights? Perhaps check ownership of the .git folder.
Perhaps check to see if there is an outstanding file lock open, maybe use lsof to check, or the equivalent for your OS.