It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

how do I keep files in a commit from being part of a merge

I'm using SourceTree and would like to merge a commit from staging back to master.  However, there are a few files in the commit that shouldn't be merged. I can't see where SourceTree allows me to mark the files to not merge. 

How can I do this?  I'd like it to be a permanent marking, so I don't accidentally merge them in the future.


2 answers

0 votes
Mikael Sandberg Community Leader Nov 01, 2016

Git does not allow you to select specific files that should be part of the merge, it is all or nothing. What you can do is create a new branch, check it out, and then use

git checkout source_branch <file_path> ...

The source branch is your staging and then specify the files that you want to merge into master. Once done, merge the branch with master and you should be all set.

This type of advanced usage can't be done in SourceTree. You'll have to drop to command line.

If you have files that should never be merged between branches, you should reconsider whether they should be tracked in the repository at all.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket Pipelines

Building a Bitbucket Pipe as a casual coder :  #!/bin/bash source "$(dirname "$0")/" enable_debug extra_args="" if [[ "${DEBUG}" == "true" ]]; then extra_args="--verbose" fi # mandatory variables R...

4,100 views 4 22
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you