I have two branches that are very different from each other, however one branch contains some useful code that I would like to add to the other branch. The branches diverged so long ago that i cannot merge them as many of their features are different and a merge is not viable.
The useful code from the donor branch was added in consecutive commits and I have the hashes of the commits I want to cherry-pick. When I give the command git cherry-pick hash1 hash2
, I am told nothing to commit, working tree clean. The previous cherry pick ous now empty, possibly due to conflict resolution.
Is there a way to run through all the cherry-picks allowing any commits that will produce no change to pass automatically? I would rather not sit here and have to manually continue through each empty cherry-pick.
That should mean, as detailed here, that all of the changes introduced by that commit have been introduced by some commit on your current branch.
First of all, double-check you have checked out first the destination branch, and you are not still on the source branch (the one with hash1 hash2
)
Then, you can skip empty commits using git rev-list as in here:
git rev-list --reverse something-begin..something-end . | git cherry-pick --stdin