Skip to content

Instantly share code, notes, and snippets.

@literat
Last active January 2, 2019 08:57
Show Gist options
  • Select an option

  • Save literat/d3ca62bf802e3191421f877b160176f9 to your computer and use it in GitHub Desktop.

Select an option

Save literat/d3ca62bf802e3191421f877b160176f9 to your computer and use it in GitHub Desktop.
Git Fixup to most recent commit

Git Fixup

~/.bin/git-log-vgrep-most-recent-commit

#! /bin/bash

if (( $# < 1 )); then
  echo >&2 "Usage: $0 pattern [<since>..<until>]"
  exit 1
fi

pattern=$1
shift

git log --format=%H $@ |
  grep -v -f <(git log --format=%H "--grep=$pattern" $@) |
  git log -1 --format="%H" --stdin --no-walk

~/.gitconfig

cif = "!git commit --fixup=`~/.bin/git-log-vgrep-most-recent-commit 'fixup!'`"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment