Merging individual file(s)

Mark Andrews April 4, 2016

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

0 votes
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.
April 4, 2016

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 Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events