git pull error :error: remote ref is at but expected
完整信息:
error: Ref refs/remotes/origin/user is at 3636498c2ea7735fdcedc9af5ab3c8689e6abe77 but expected a21359c6cc2097c85775cde6a40105f4bd7100ec
From github.com:{github project url}
! a21359c..6273ffc user -> origin/user (unable to update local ref)
If you are running git under a file system that is not case sensitive (Windows or OS X) this will occur if there are two branches with the same name but different capitalisation, eg user_model_changes
and User_model_changes
as both of the remote branches will match the same tracking ref.
Delete the wrong remote branch (you shouldn't have branches that differ only by case) and then git remote prune origin
and everything should work
Permanent Fix
git update-ref -d
resolved my instance of this error, eg
git update-ref -d refs/remotes/origin/user
Note that this doesn't impact remote.
In my case, a subsequent git fetch
fetched that branch again, and following git fetches/pulls no longer gave the error "remote ref is at but expected".
If that doesn't work, a temporary fix:
Note also that if you don't care about the branch in question (eg you just want to update master, not origin/user), a git pull
workaround is to fetch then just merge the particular branch you care about, eg
git fetch # may give an error for a particular branch, but other branches will still be successfully fetched
git merge origin/master
Just delete the folders and files under ".gitrefsremotesorigin". Works when u dont have unpushed changes
链接地址: http://www.djcxy.com/p/26096.html上一篇: 为什么我需要明确推送新分支?