Merge a Feature with multiple commits over time into another project

Asked

Viewed 69 times

2

Has a Feature tenis with multiple commits over time, and need to merge this another project.

Consider this time line:

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

I want:

- tenisV1 - tenisV2 - tenisV3 - tenisV4

How can I fix this?

I was thinking of showing off the diff of all these commits merged to help me, but I don’t know how to do that without showing changes to unrelated commits in the middle of the timeline (commits x).

I’m using git and also bitbucket so if there’s something visual there would be cool too.

2 answers

2


You can use the command Cherry-pick. You choose the commits you want and bring them to the branch you’re in.

In the commit you want to replicate do

- git log

The answer will be something like this:

- "9ce8fa5a3d3a3555222eabb234df93cc5447####" 

The result will be the commit ID, copy it, check out for your new Source.

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

Repeat the process for all commit in order.

2

Complementing the @Marcelfelipe response

You can also use Cherry-pick with multiple commits if they are in order, for example, consider commits A - B - C - D, with older A and younger D:

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

Observing: ^ also includes commit A

In case the order is messy, the command will fail silently, source.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.