Git and nasty “error: cannot lock existing info/refs fatal”

后端 未结 24 1362
礼貌的吻别
礼貌的吻别 2020-11-30 15:58

After cloning from remote git repository (at bettercodes) I made some changes, commited and tried to push:

git push origin master

Errors

相关标签:
24条回答
  • 2020-11-30 16:56

    In my case I had to manually delete old tags which had been removed on remote.

    0 讨论(0)
  • 2020-11-30 16:58

    Run git fetch --all before git pull. That should solve the problem.

    0 讨论(0)
  • 2020-11-30 16:59

    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.

    0 讨论(0)
  • 2020-11-30 17:00

    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.

    0 讨论(0)
  • 2020-11-30 17:02

    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>
    
    0 讨论(0)
  • 2020-11-30 17:02

    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.

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