user3948
user3948

Reputation: 83

use git cherry-pick now but merge changes later

I have two branches and want to cherry-pick a change from one and move it to the other. At a later date, when I merge the two repositories what effect will the cherry-pick have since the commit IDs will be different but the content will be the same.

Upvotes: 8

Views: 876

Answers (2)

pevik
pevik

Reputation: 4781

This approach expect that the other branch (fix-branch) hasn't been pushed to origin (=> it can be rebased). To avoid that, we can rebase instead of merge:

git rebase master fix-branch

Now we are in fix-branch, master is bellow. Continue to switch back to master and merge:

git checkout master
git merge fix-branch

Source

Upvotes: 0

cdhowie
cdhowie

Reputation: 168988

As long as the changed region is not affected in a later commit, the merge will ignore the regions changed in the cherry-pick, since they will be identical in each branch. If you later change one of the regions in one branch but not the other, you may have to resolve a conflict as usual.

Upvotes: 7

Related Questions