I have had two feature branches, that have been requested to merge at some point. Now i need to use one of the commits after the merge just for one branch. Is there easy way how to move this commit to the other branch? (As far as i have checked the files pushed in this commit are not changed in other commits after merge)
Asked
Active
Viewed 43 times
0
-
3You can use `git cherry-pick
` to create a new commit that contains the same changes as the commit with id – kowsky Mar 22 '18 at 13:43. -
1You can cherrypick , check this https://stackoverflow.com/questions/9339429/what-does-cherry-picking-a-commit-with-git-mean – prudviraj Mar 22 '18 at 13:43
-
1https://stackoverflow.com/questions/9339429/what-does-cherry-picking-a-commit-with-git-mean – evolutionxbox Mar 22 '18 at 13:45
-
Sorry @prudviraj I didn't see the link you posted. --- OP, are you aware what you need to do now? – evolutionxbox Mar 22 '18 at 13:58
-
You can cherry pick it but you'll encounter merge conflicts (or worse, some changes will be ignored or reverted without triggering a conflict) on merge. Read this [series of articles](https://blogs.msdn.microsoft.com/oldnewthing/20180312-00/?p=98215) about how to merge instead of cherry-pick to solve such situations. – axiac Mar 22 '18 at 14:10
1 Answers
0
You can use cherry-pick. If you want to have commit from one branch to targeted branch then use cherry-pick.
git cherry-pick:
checkout/switch to your targeted branch.
> git checkout <targeted branch>
Then use cherry-pick:
>git cherry-pick <commit id>
note: <commit id> is the commit id of another branch you want to use in your
targeted branch .
Ex:
git cherry-pick f1f17bc7cd4799377a7dbc39211b0f0a5820bf92

Mamun Kayum
- 161
- 7