Reputation: 2253
I'm using a shared git repository that has two main branches, one for product delivery and one for a specific testing platform. There is a fixed set of differences between the two that must be maintained (several thousand additional files, plus some changes to existing files), but other than that I'd like to merge changes in either branch into the other.
Problem: each time I merge from one into the other, that set of differences is included, so I have to remove the differences before completing the merge. This happens in both directions, so I'm forever picking the real changes out of the "fake" changes.
How can I maintain these two branches in a Git-friendly way, such that I don't keep having to persuade Git to ignore those changes?
Upvotes: 3
Views: 649
Reputation: 1056
Find out the commit hash of the commit you want to merge. (e.g. 96f402f1391
)
Then check out the branch you want to merge to and use cherry-pick
git cherry-pick 96f402f1391
Upvotes: -1
Reputation: 2253
The correct way to do this is as follows:
Git will remember the "fixed" differences between the two branches as the product of the historical commits on the dependent branch, and those differences will be preserved when merging from the master into the dependent. As I noticed, Git tries to bring those differences back into the master branch if if I merge from the dependent back to the master; cherry-picking avoids those changes, only bringing over the "new" differences. (This does mean that you have to keep track of the dependent commits that must be brought over into the main, but there doesn't seem to be a way around this.)
Upvotes: 3