Merge a feature with multiple commits over time in another project

2

It has a tenis feature with multiple commits over time, and you need to merge this feature into other project.

Consider this timeline:

- x - tenisV1 - x - x - tenisV2 - x - tenisV3 - x - x - x - x - x - tenisV4

I want to:

- tenisV1 - tenisV2 - tenisV3 - tenisV4

How can I resolve this?

I was thinking about displaying diff of all these merged commits to help me, but I do not know how to do this without showing changes to unrelated commits in the middle of the timeline ( commits x ) .

I'm using git and also bitbucket so if you have something visual there would be nice too.

    
asked by anonymous 03.08.2018 / 22:06

2 answers

2

You can use the cherry-pick command. You choose the commits you want and bring them to the branch you are in.

In the commit you want to replicate do

- git log

The answer will look something like this:

- "9ce8fa5a3d3a3555222eabb234df93cc5447####" 

The result will be the commit ID, copy it, checkout for your new feature.

- git checkout "nome da branch".
- git cherry-pick "9ce8fa5a3d3a3555222eabb234df93cc5447####"

Repeat the process for all commits in order.

    
03.08.2018 / 22:28
2

Complementing the response from @MarcelFelipe

You can also use the cherry-pick with several commits if they are in order, for example, consider commits A-B-C-D, where A is the oldest and D the newest:

git checkout branch-destino
git cherry-pick A^..D

Note: ^ is also meant to include commit A

If the order is messy, the command will fail silently, source .

    
04.08.2018 / 00:38