Created
May 14, 2024 13:27
-
-
Save klaseskilson/880050438fdf05c0d4732a29181ea934 to your computer and use it in GitHub Desktop.
Git Fixup commit with commit chooser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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