# find the commits you want to remove, e.g. using all commits that added or changed a file
$ git whatchanged -- path/to/file [...] > files.lst
$ git whatadded -- path/to/file [...] >> files.lst
# then do a rebase to get all commits that were added since then, including the ones you want to exclude
$ git rebase -i <commit>
# when rebase stops it will have created .git/rebase-merge/git-rebase-todo
# then do the following. this will take the commit ids from files.lst and
# remove every line in git rebase-todo
$ cat files.lst | cut -b1-7 | xargs -L1 -I {} sed -i '/{}/d' /home/patrick/projects/shrebo-ext/.git/rebase-merge/git-rebase-todo
Created
December 27, 2014 14:42
-
-
Save miraculixx/db9bb619a1b0d4a55972 to your computer and use it in GitHub Desktop.
find and remove specific git commits using rebase
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment