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

这一生的挚爱 提交于 2019-12-01 15:04:01
Vasilisfoo

I had the same problem and the only solution that I found was to navigate to the head like so :

.git/refs/heads/branch_name

And I deleted the head file . Then I went to the console and I used the command :

git reset

Then all the files were unstaged so add them and commit them afterwards.

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

Worked for me, into terminal enter: (branch accordingly to your desires lul)

echo ref: refs/heads/master >.git/HEAD

If you don't mind losing your history, you can delete the .git file and then

git init

This will reinitialize your repository and you can then proceed from there

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

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).

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>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!