Skip to content

Instantly share code, notes, and snippets.

@micoli
Created March 10, 2020 04:42
Show Gist options
  • Select an option

  • Save micoli/8605b49af16cf89f34480882600391bb to your computer and use it in GitHub Desktop.

Select an option

Save micoli/8605b49af16cf89f34480882600391bb to your computer and use it in GitHub Desktop.
[alias]
...
# fixup for a file, using the commit where it was last modified
fixup-file = "!sh -c '\
[ $(git diff --numstat $1 | wc -l) -eq 1 ] && git add $1 && \
[ $(git diff --cached --numstat $1 | wc -l) -eq 1 ] || (echo No changes staged. ; exit 1) && \
COMMIT=$(git log -n 1 --pretty=format:"%H" $1) && \
git commit --fixup=$COMMIT "
#&& \ git rebase -i --autosquash $COMMIT~1' -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment