Git error on git pull (unable to update local ref)

2019-01-21 10:43发布

I only have branch master and im getting this error every time i try to "git pull":

error: Couldn't set refs/remotes/origin/master
From /var/lib/git/xxx/project
 ! a0f80ea..49177a3  master     -> origin/master  (unable to update local ref)

and when i do "git pull origin master" i get:

error: Couldn't set ORIG_HEAD
fatal: Cannot update the ref 'ORIG_HEAD'.

i have been searching but cant find why

11条回答
2楼-- · 2019-01-21 10:58

Ensure the user that is executing the git pull is the same user that created the repository. The file permissions are incorrect.

查看更多
Evening l夕情丶
3楼-- · 2019-01-21 10:58

rm .git/refs/remotes/origin/master

It works to me!

查看更多
家丑人穷心不美
4楼-- · 2019-01-21 11:01

My team and I ran into this error, unable to update local ref, when doing a pull in SourceTree.

We used :

git gc --prune=now

This removes any duplicate reference objects which should fix the issue.

Here are a few links where you can learn more about git references and pruning :

git tip of the week

git-prune documentation

git references

查看更多
一纸荒年 Trace。
5楼-- · 2019-01-21 11:02

Try to use this command in your git repository root folder:

rm .git/logs/refs/remotes/origin/master 
查看更多
再贱就再见
6楼-- · 2019-01-21 11:03

Clone the repository again, and copy the .git folder in your broken project.

查看更多
Animai°情兽
7楼-- · 2019-01-21 11:07

I discoverd the same Error message trying to pull from a Bitbuck Repo into my lokal copy. There is also only one Branche Master and the command git pull origin master lead to this Error Message

From https://bitbucket.org/xxx
 * branch            master     -> FETCH_HEAD
error: Couldn't set ORIG_HEAD
fatal: Cannot update the ref 'ORIG_HEAD'.

Solution as follows

  1. git reflog find the number of the last commit
  2. git reset --hard <numnber> reset to the last commit
  3. git pull origin master pull again without error
查看更多
登录 后发表回答