I ran a git pull
that ended in a conflict. I resolved the conflict and everything is fine now (I used mergetool also).
When I commit the resolved file with git commit file.php -m "message"
I get the error:
fatal: cannot do a partial commit during a merge.
I had the same issue before and using -a
in commit worked perfectly. I think it's not the perfect way because I don't want to commit all changes. I want to commit files separately with separate comments. How can I do that? Why doesn't git allow users to commit files separately after a merge? I could not find a satisfactory answer to this problem.
This worked for me. You can try this also.
As the error message says you cannot do a partial commit after a merge. Instead of committing just
file.php
you should commit all the changes.This should work.
If you just want to ditch the whole cherry-picking and commit files in whatever sets you want,
gets you there.
What soft reset does is it moves the pointer pointing to current HEAD to the commit(ish) you gave but does not alter the files. Hard reset would move the pointer and also revert all files to the state in that commit(ish). This means with soft reset you can clear the merge status but keep the changes to actual files and then commit or reset them each individually per your liking.
You probably got a conflict in something that you haven't staged for commit. git won't let you commit things independently (because it's all part of the merge, I guess), so you need to
git add
that file and thengit commit -m "Merge conflict resolution"
. The-i
flag forgit commit
does the add for you.Your merge stopped in the middle of the action. You should add your files, and then 'git commit':
git add file_1.php file_2.php file_3.php git commit
Cheers
For myself this happened in SourceTree when I tried to commit a merge before resolving all of the files. I then marked the last file resolved and yet it still gave me this error when trying to commit. I closed SourceTree and reopened it, and then it committed fine.