Git cannot lock ref 'HEAD': unable to resolve reference HEAD

后端 未结 10 1473
情深已故
情深已故 2020-12-15 16:57

I\'m trying to commit the changes to my repository but I receive the error below:

git -c diff.mnemonicprefix=false -c core.quotepath=false commit -q -F C:\\U         


        
相关标签:
10条回答
  • 2020-12-15 17:09

    Navigate to directory

    .git/refs/heads/branch_name

    delete the preferred branch name

    then open terminal(git bash or cmd for windows)

    git reset
    

    then commit the changes (if necessary)

    then run the following command for merging the remote repository branch

    git pull
    

    if it gives related to refusing to merge unrelated histories

    then, run the following command in the terminal

    git pull origin master --allow-unrelated-histories
    

    this solution solved my problem

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

    I have the same problem. I just used command:

    git reset
    

    Than I removed file /my_project_directory/./git/refs/heads/master and than I can use command

    git reset --hard <my_hash_of_last_commit_on_remote_branch>
    
    0 讨论(0)
  • 2020-12-15 17:13

    I had the same problem, this worked for me:

    Step 1) - got to .git\logs\refs\heads and open the Document named as YOUR_BRANCH, now copy the ID -numbers in front of your user name and email-

    Step 2) - got to .git\refs\heads and open the document named as YOUR_BRANCH delete the line and paste the ID in.

    Hope it works for you to

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

    I had the same issue after calling git commands with the root user inside the working copy. So the owner and owner group of various files under .git/ were changed to "root".

    When I switched back to my user account, git could not handle this files anymore, because of the lacking permissions.

    It worked again, after resetting the permissions with

    sudo chown -R [MY_USER]:[MY_GROUP] .git
    
    0 讨论(0)
  • 2020-12-15 17:17

    This is what fixed my issue:

     rm -rf .git/refs/heads/
    
    0 讨论(0)
  • 2020-12-15 17:22

    When I run into this I just git clone the project into a new file directory and pull the heads folder from located at .git\refs\heads and replace the original heads file in the directory that your having the problem. Then just delete the new clone you created (since it obviously doesn't have the updates your trying to push).

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