Skip to content

Instantly share code, notes, and snippets.

@klaseskilson
Created May 14, 2024 13:27
Show Gist options
  • Save klaseskilson/880050438fdf05c0d4732a29181ea934 to your computer and use it in GitHub Desktop.
Save klaseskilson/880050438fdf05c0d4732a29181ea934 to your computer and use it in GitHub Desktop.
Git Fixup commit with commit chooser
#!/bin/bash
# gfucc = git fixup commit chooser. needs fzf and git.
# Present a list to choose a commit
selected_hash=$(git log --pretty=format:"%C(auto)%h%Creset -%C(auto)%d%Creset %s (%C(green)%cr%Creset)" --color=always | fzf --ansi --preview 'git show --color=always {1}' --exit-0 | cut -d ' ' -f 1)
# See if something was selected and commit to that hash
if [ -n "$selected_hash" ]; then
git commit --fixup=$selected_hash "$@"
else
echo "No commit selected."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment