Skip to content

Instantly share code, notes, and snippets.

@jmrnilsson
Created October 10, 2018 11:03
Show Gist options
  • Save jmrnilsson/b5fb81770ef92578d6e366bfcb47f629 to your computer and use it in GitHub Desktop.
Save jmrnilsson/b5fb81770ef92578d6e366bfcb47f629 to your computer and use it in GitHub Desktop.
Git revert if there are merge commits also
#!/usr/bin/env bash
SHA=$1
echo "Creating file list for $SHA"
git diff-tree --no-commit-id --name-only -r "$SHA" >
vim diff-tree.filelist
cat diff-tree.filelist | xargs -0 -I -r {} git checkout "$SHA^" {}
rm diff-tree.filelist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment