Sourcetree merge branch into master automatically commits - why?

Simon Dib August 18, 2014

Sometimes when I merge a branch into master the files automatically commit themselves ready for a push. Typically I would expect a merge to first appear in the Working Copy area so I can review which files I do actually want to commit or remove.

Am I performing the merge incorrectly? While I'm in the Master branch I right-click on the branch to merge in then click "Merge branch into master".

Confusingly this problem only happens some of the time. On occasion the files do appear in the Working Copy area as expected.

Any suggestions welcome!

1 answer

1 accepted

2 votes
Answer accepted
Seth
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 18, 2014

This happens because it is the way Git is designed to operate. The occasions when the files do NOT automatically commit are almost always because there is a conflict that needs resolved before you can commit.

There is good news, though. The fact that the merge is committed does not, in any way, prevent you from reviewing and modifying the changes. Review the diffs in the commit details, make any changes you need to make. Then, when you commit, select "amend previous commit".

Simon Dib August 19, 2014

Ok, thanks that makes sense. One other question though - when it auto-commits it doesn't give me a chance to add a log message. For example, if I merge from branchA into master I'd like to add "Merge 'branchA' into Master". Instead what actually happens is it uses the last commit message from that branch.

From what you've suggest it sounds like I could do an "amend previous commit" and add the message there, but it seems like an extra unneccessary step, especially if I don't have any further actual file amendments?

Hope this makes sense .. ?

Seth
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 19, 2014

That does makes sense, but doesn't match the behavior of SourceTree on my machine. When I merge, the automatically-generated commit message is something like "Merge branch 'branchA' into master".

You might try a command line merge and see what commit message it uses.

erumhannan January 26, 2017

@Seth  this is also happening on my side its not creating merge commit that is "Merge branch 'branchA' into master"

Seth
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 30, 2017

When the merge comfirmation dialog opens, there is an option to "Create a new commit even if a fast forward is possible" - try that.

What is probably happening is that no changes were made to master between when you created your branch and when you merged it back. In that scenario, there isn't actually anything to merge, so by default git will instead "fast-forward" the master branch to the last commit on branchA. The option I mentioned will force git to create a new commit anyway (which is often preferred when dealing with a "master" or "dev" branch).

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events