I have a branch into which I accidentally merged other peoples changes a long time ago, and now hundreds of files show up on a pull request that are not mine.
I would like to create a separate branch into which I would like to cherry-pick changes to my own files over those several dozen commits, so that my new pull request only contains my changes.
I found out how to cherry pick commits, and how to cherry pick files from one specific commit, but how do I cherry pick several files from a range of commits?
Is there perhaps a simpler solution?
If there is a single commit that you used to merge in, that you can avoid, then use
git rebase
to skip the merging commit.If instead your changes (
B
,C
, andD
above) actually touch the files you're trying to avoid, you'll need to usegit filter-branch
to rewrite those commits and avoid changing those files. Using the--tree-filter
command, you can reset the part of each tree that you don't want to touch.