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:\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'm using bitbucket and SourceTree.
What's the reason for this commit failing? I was able to commit just fine the last 3 commits over the past week. Then, all of a sudden, I receive 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 directory .git/objects/53/b65bd9b4fec7f6a7b0b3313c68199a18804327
but that doesn't exist. There's two other files there, but b65bd9b4fec7f6a7b0b3313c68199a18804327
doesn't exist.
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.
.git\logs\refs\heads
and open the Document named as YOUR_BRANCH
, now copy the ID
numbers in front of your user name and emailStep 2.
.git\refs\heads
and open the document named as YOUR_BRANCH
delete the line and paste the ID
in.Navigate to directory .git/refs/heads/branch_name
Delete the preferred branch name
Open terminal(git bash or cmd for windows)
git reset
Commit the changes (if necessary)
Run the following command for merging the remote repository branch
git pull
If it gives related to refusing to merge unrelated histories, run the following command in the terminal:
git pull origin master --allow-unrelated-histories
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With