The error that you are seeing:
error: Your local changes to 'foo.cpp' would be overwritten by merge. Aborting. Please, commit your changes or stash them before you can merge.
is because you have uncommitted changes
(it says this at the very top of the SourceTree display). Any attempt to merge will fail if you have uncommited changes. You have three choices:
- Axe all the changes (Use:
git reset --hard
) - Stash all the changes (Use:
git stash
) - Commit all the changes (use:
git add ...; git commit ...
)
After you've done that you will be allowed to merge. If you choose option #3 above then conflicts might arise; there will be no conflicts for options #1 or #2. [Note: for option #2, you will do git stash pop
later and conflicts might arise then.]
For your Q1: do git config merge.tool diff3
(or vimdiff, or whatever). Merging can be confusing (it is typically a 3-way merge so the tool shows three versions and a combined version).
For your Q2: SourceTree does not include it's own merge tool; you'll need to rely on another (I use p4merge and SourceTree). With these config options:
difftool.sourcetree.cmd=/Applications/p4merge.app/Contents/MacOS/p4merge "$LOCAL" "$REMOTE"
difftool.sourcetree.path=
mergetool.sourcetree.cmd=/Applications/p4merge.app/Contents/MacOS/p4merge "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
mergetool.sourcetree.trustexitcode=true