Skip to content

Instantly share code, notes, and snippets.

@s7anley
Last active May 18, 2017 15:13
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 s7anley/115ca5ad6e01829c2f4196917320c082 to your computer and use it in GitHub Desktop.
Save s7anley/115ca5ad6e01829c2f4196917320c082 to your computer and use it in GitHub Desktop.
Amend of history commit for forgotten file.
#!/usr/bin/env bash
$(git diff-index --quiet HEAD $1) > /dev/null
FILE_CHANGED=$?
if [ $FILE_CHANGED -eq 1 ];then
COMMIT=$(git log -n 1 --pretty=format:%H -- $1)
git add $1
git commit --fixup=$COMMIT
git rebase --interactive --autosquash $COMMIT^
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment