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’.

  • How to make automatic pull request with Sourcetree NOT in master branch?
  • Git pre-commit hook failing in GitHub for mac (works on command line)
  • How to create tag automatically in SourceTree
  • Removing/undoing a merge on Sourcetree
  • Why did sourcetree delete my commit?
  • SourceTree: Error when opening repository (OSX)
  • 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.

  • Using go language with gitolite
  • gitignore: Understanding “hello/” vs. “hello/*”
  • How to quickly switch source control providers in Visual Studio 2010?
  • How do I sync automatically my project in Sublime Text 2 on a remote server when I'm using Git?
  • Git: Your branch and 'origin/master' have diverged - after updating forked repo
  • What's the simplest way to pull from master and merge it to your branch?
  • One Solution collect form web for “Git: cannot do a partial commit during a merge (SourceTree)”

    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}
    
    Git Baby is a git and github fan, let's start git clone.