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

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

    Before pull you need to clean your local changes. following command help me to solve.

    git remote prune origin
    

    and then after

    git pull origin develop
    

    Hopes this helps!

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

    This is probably resolved by now. But here is what worked for me.

    1. Location:

      • If locked repository is on the server-side:

        1. ssh to your git repository on the server.
        2. Login as user which has permissions to modify the repository and navigate to the repository on your server.
      • If locked repository is local only:

        1. Open the git console and navigate to the repository directory.
        2. Run this command:

          git update-server-info
          
    2. Fix the permissions on your (remote or/and local) repository if you have to. In my case I had to chmod to 777 and chown to apache:apache

    3. Try to push again from the local repository:

      git push
      
    0 讨论(0)
  • 2020-11-30 16:54

    Update:

    You might need to edit your ~/.netrc file:

    https://bugs.launchpad.net/ubuntu/+source/git-core/+bug/293553

    Original answer:

    Why did you disable ssl? I think this might have to do with you not being able to push via https. I'd set it back and try to push again:

    git config –global http.sslVerify true
    
    0 讨论(0)
  • 2020-11-30 16:55

    This is what I did to get rid of all the lock ref issues:

    git gc --prune=now
    git remote prune origin
    

    This is probably what you only need to do too.

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

    In case of bettercodes.org, the solution is more poetic - the only problem may be in rights assigned to the project members. Simple members don't have write rights! Please make sure that you have the Moderator or Administrator rights. This needs to be set at bettercodes.org at the project settings by an Administrator, of course.

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

    For me this worked:

    git remote prune origin

    Since this answer seems to help a lot of people, I dug a little bit into what actually happens here. What this will do is remove references to remote branches in the folder .git/refs/remotes/origin. So this will not affect your local branches and it will not change anything remote, but it will update the local references you have to remote branches. It seems in some cases these references can contain data Git cannot handle correctly.

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