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

后端 未结 18 1758
鱼传尺愫
鱼传尺愫 2020-12-12 11:25

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/p         


        
相关标签:
18条回答
  • 2020-12-12 12:10

    This work for me

    rm .git/logs/refs/remotes/origin/master 
    
    0 讨论(0)
  • 2020-12-12 12:11

    This is probably a very niche situation, but: I run Windows in a Parallels VM on my MacBook Pro, with my local repos stored on the VM's disk, which is shared with macOS.

    If I have a file open in a Mac app from a repo that's located on the Windows VM, I sometimes get the "unable to update local ref" error. The solution when this happens is to simply close the file or quit the Mac app.

    0 讨论(0)
  • 2020-12-12 12:14

    rm .git/refs/remotes/origin/master

    It works to me!

    0 讨论(0)
  • 2020-12-12 12:15

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

    Update 2020: Per @Edward Yang's answer below, @bryan's comment on this answer, and this question/answer you may need to run both git gc --prune=now and git remote prune origin. Running only the former has always worked for me but based on ppl's responses I think both are necessary to address different causes of the error.

    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

    0 讨论(0)
  • 2020-12-12 12:16

    Speaking from a PC user - Reboot.

    Honestly, it worked for me. I've solved two strange git issues I thought were corruptions this way.

    0 讨论(0)
  • 2020-12-12 12:21

    I solved as below:

    git remote prune origin

    0 讨论(0)
提交回复
热议问题