Skip to content

Instantly share code, notes, and snippets.

@lengerfulluse
Created September 6, 2016 09:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lengerfulluse/f84e1163fe1b7800ebb12cefda91445a to your computer and use it in GitHub Desktop.
Save lengerfulluse/f84e1163fe1b7800ebb12cefda91445a to your computer and use it in GitHub Desktop.
git revert a specific file in a commit script
#!/bin/bash
function output_help {
echo "usage: git-revert-single-file <sha1> <file>"
}
sha1=$1
file=$2
if [[ $sha1 ]]; then
git diff $sha1..$sha1^ -- $file | patch -p1
else
output_help
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment