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

后端 未结 18 1759
鱼传尺愫
鱼传尺愫 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:21

    What worked for me was:

    git config --global fetch.prune true
    

    Now it keeps on running prune automatically.

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

    I had the same error, I was updating from within Eclipse and I got many errors. So I tried updating from a DOS command window, and got the same issue.

    Then I tried the solution " git gc --prune=now " This gave messages that the files were locked in the refs directory.

    Eclipse must have had a locked on something in the "refs" directory.
    The solution I found was to simply close Eclipse. Then I updated the repository from DOS with a " git PULL " command, and everything worked fine.

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

    What happened over here? The local references to your remote branches were changed and hence when you run git pull, git doesn't find any corresponding remote branches and hence it fails.

    git remote prune origin
    

    actually cleans this local references and then run git pull again.

    Suggestion - Please run with --dry-run option for safety

    0 讨论(0)
  • 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
    0 讨论(0)
  • 2020-12-12 12:26

    with gitbach line commande, use git update-ref to update reference of your local branch:

    $ git update-ref -d refs/remotes/origin/[locked branch name]
    

    then pull using $ git pull

    [locked branch name] is the name of the branch that the error is happening because of mismatch of commit Ids.

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

    This happened to me on OSX where I use a case insensitive file system. Somehow another developer pushed a branch with the same name but different case: My-Branch vs my-branch.

    I already had My-Branch checked out and got the error "unable to update local ref" when I did a pull probably because the file system thinks My-Branch == my-branch.

    Since we use Github I could solve the problem by deleting one of the branches via Github's GUI.

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