Git cannot block ref 'HEAD': failed to execute HEAD link

I try to commit changes to my repository, but I get the following message:

git -c diff.mnemonicprefix=false -c core.quotepath=false commit -q -FC:\Users\Contronym\AppData\Local\Temp\bkdweixb.mnu fatal: cannot lock ref 'HEAD': unable to resolve reference HEAD: Invalid argument Completed with errors, see above. 

I use bitbucket and SourceTree.

What is the cause of this failure? Over the past week, I was able to fix the last 3 commits. Then, all of a sudden, I get this error.

EDIT

I ran git gc and these are the results:

 $ git gc error: bad ref for HEAD error: bad ref for HEAD error: inflate: data stream error (unknown compression method) fatal: loose object 53b65bd9b4fec7f6a7b0b3313c68199a18804327 (stored in .git/objects/53/b65bd9b4fec7f6a7b0b3313c68199a18804327) is corrupt error: failed to run repack 

I checked the .git/objects/53/b65bd9b4fec7f6a7b0b3313c68199a18804327 , but this does not exist. There are two more files there, but b65bd9b4fec7f6a7b0b3313c68199a18804327 does not exist.

+16
source share
7 answers

I had the same problem, and the only solution I found was to go to the head as follows:

.git / links / heads / branch_name

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

 git reset 

Then all the files were deleted, so add them and commit them later.

+13
source

I had the same problem, this worked for me:

Step 1) - go to .git \ logs \ refs \ head and open a Document with the name YOUR_BRANCH , now copy the identifier -numbers in front of your username and email-

Step 2) - got to .git \ refs \ head and open a document called YOUR_BRANCH, delete the line and paste the ID into.

Hope this helps you

+3
source

Worked for me, enter the terminal: (branch according to your desires lul)

 echo ref: refs/heads/master >.git/HEAD 
+1
source

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

 git init 

This will re-initialize your repository and you can continue

+1
source

I had the same problem after calling git commands with root user inside a working copy. Thus, the owner and group of owners of various files in.git / were changed to "root".

When I returned to my account, git could no longer process these files due to lack of permissions.

Again earned, after resetting permissions with

 sudo chown -R [MY_USER]:[MY_GROUP] .git 
0
source

When I come across this, I just git clone the project into a new directory with files and pull out the header folder from .git \ refs \ head and replace the original header file in the directory where you have a problem. Then just delete the new clone that you created (since it obviously does not have the updates you are trying to send).

0
source

I have the same problem. I just used the command:

 git reset 

How did I delete the file / my _project_directory /./ git / refs / heads / master and how can I use the command

 git reset --hard <my_hash_of_last_commit_on_remote_branch> 
-2
source

All Articles