Merging individual file(s)

I have been working for sometime on a development branch. During this time I have changed and committed many files. The changes to one file, a shared library file, now need to be merged onto the master branch while leaving other files unchanged. How can this, merging one or more specific files from one branch to another, be achieved?

1 answer

If there is a specific commit or set of commits that contain the changes you need (and none of the changes you don't), you can "cherry pick" the commits into another branch.

Otherwise, you'll need to copy the changes by hand. Merges effect the entire working copy.

You could do a merge and amend the merge commit to remove all the changes for the other files, but Git would see that as a commit that reverses those changes, and you'd have big problems if you decide to really merge those changes later on.

EDIT: Git does allow for "submodules" and "subtrees", which might give you the workflow you need, but I've never used them, and it doesn't sound like your library file is set up that way currently.

Suggest an answer

Log in or Join to answer
Community showcase
Brian Ganninger
Published Jan 23, 2018 in Sourcetree

Tip from the team: workflow and keyboard shortcuts

Supported Platforms macOS Sourcetree has a lot to offer and, like many developer tools, finding and using it all can be a challenge, especially for a new user. Everyone might not love ...

256 views 0 3
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot