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

后端 未结 24 1360
礼貌的吻别
礼貌的吻别 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:37

    This happened to me when my git remote (bitbucket.org) changed their IP address. The quick fix was to remove and re-add the remote, then everything worked as expected. If you're not familiar with how to remove and re-add a remote in git, here are the steps:

    1. Copy the SSH git URL of your existing remote. You can print it to the terminal using this command:

      git remote -v

    which will print out something like this:

     origin git@server-address.org:account-name/repo-name.git (fetch)
     origin git@server-address.org:account-name/repo-name.git (push)
    
    1. Remove the remote from your local git repo:

      git remote rm origin

    2. Add the remote back to your local repo:

      git remote add origin git@server-address.org:account-name/repo-name.git

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

    This is how it works for me.

    1. look up the Apache DAV lock file on your server (e.g. /var/lock/apache2/DAVlock)
    2. delete it
    3. recreate it with write permissions for the webserver
    4. restart the webserver

    Even faster alternative:

    1. look up the Apache DAV lock file on your server (e.g. /var/lock/apache2/DAVlock)
    2. Empty the file: cat /dev/null > /var/lock/apache2/DAVlock
    3. restart the webserver
    0 讨论(0)
  • 2020-11-30 16:40

    What worked for me was:

    1. Remove .git/logs/refs/remotes/origin/branch
    2. Remove .git/refs/remotes/origin/branch
    3. Run git gc --prune=now
    0 讨论(0)
  • 2020-11-30 16:40

    Check that you (git process actually) have access to file .git/info/refs and this file isn't locked by another process.

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

    Running command git update-ref -d refs/heads/origin/branch fixed it.

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

    Aside from the many answers already supplied to this question, a simple check on the local repo branches that exist in your machine and those that don't in the remote, will help. In which case you don't use the

    git prune

    command as many have suggested.

    Simply delete the local branch

    git branch -d <branch name without a remote tracking branch by the same name>
    

    as shown in the attached screenshot using -D to force delete when you are sure that a local branch does not have a remote branch tracked.

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