Skip to content

Instantly share code, notes, and snippets.

@schnell18
Last active August 29, 2015 13:57
Show Gist options
  • Save schnell18/9619727 to your computer and use it in GitHub Desktop.
Save schnell18/9619727 to your computer and use it in GitHub Desktop.
Automate git rebase -i to remove selected commits
# Perl onliner is used to delete selected commits from the git rebase -i commit text
# The range of commits includes extra commit to prevent git from doing noop when
# all commits after certain point are to be backed out.
# Some notes on the Perl onliner:
# -n: run the script as specified by -e in the while(<>) loop
# -i: modify the file inplace
# -e: command to run
env GIT_SEQUENCE_EDITOR="perl -ni -e 'print unless /^pick (7d105ae|08fe503|97bf990)/'" git rebase -i <earliest_commit_to_backout>^^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment