Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: cannot do a partial commit during a merge (SourceTree)

After updating the SourceTree to it's latest version I am fighting with this issue. Assume following scenario:

There are file A, B and C under the version control and there is just one branch. In my working copy, I make some changes to the file A so it turns into a A' as well as the file B to B'. Someone else in his working copy makes a change to the file C -> C'.

I stage and commit my changes to the file B only. So I have a new revision: A, B', C and working copy A', B', C.

The other one commits his changes, so he makes a revision A, B, C' and pushes it to the origin.

And here it comes. When I perform the pull, I get some merge changes (the C'). And I want to commit a revision consisting of A, B', C'. I do not want to do now anything with the modified file A. However, the GIT, SourceTree resp., fails with:

fatal: cannot do a partial commit during a merge.

untill I stage or discard changes to the file A.

I am pretty sure the some previous version of SourceTree did not expose this behavior.

Update 2017/05

It appears in the most recent SourceTree version 2.0.20.1 this issue has been resolved. However, be sure you want to update to this version, because it contains lot of "bugs" (new features) I really dislike.

like image 701
Jan Drozen Avatar asked Sep 21 '16 12:09

Jan Drozen


1 Answers

fatal: cannot do a partial commit during a merge.

This indicates that your merge is still in progress, there could be some conflicts which you still need to resolve.

Please select Conflicts from the drop down box as screenshot and you should be able to see a list of conflicted files with a triangle icon. Resolving these and then doing a commit should fix your problem.

enter image description here

This post should give a brief idea of how to configure and use an external tool to resolve merge conflicts - How to interactively (visually) resolve conflicts in SourceTree / git

If you still can't make up, you may stash your changes. Pull from origin and apply stash to fix the same.

Edits

You can also automate all such operations using "custom action". One sample script to do a stash >> pull >> apply stash is copied below

git -c diff.mnemonicprefix=false -c core.quotepath=false stash save temp
git -c diff.mnemonicprefix=false -c core.quotepath=false fetch origin
git -c diff.mnemonicprefix=false -c core.quotepath=false pull origin <<local path goes here>>
git -c diff.mnemonicprefix=false -c core.quotepath=false submodule update --init --recursive
git -c diff.mnemonicprefix=false -c core.quotepath=false stash apply stash@{0}
like image 137
Arvin Avatar answered Sep 16 '22 12:09

Arvin