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
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
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>
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
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
This is what fixed my issue:
rm -rf .git/refs/heads/
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).