Skip to content

Instantly share code, notes, and snippets.

@sirtawast
Created November 3, 2025 12:03
Show Gist options
  • Save sirtawast/ab18f50b39d33b772336437dad940b14 to your computer and use it in GitHub Desktop.
Save sirtawast/ab18f50b39d33b772336437dad940b14 to your computer and use it in GitHub Desktop.
for file in $(git diff --name-only --cached); do
previous_commit=$(git rev-list -1 HEAD -- $file)
previous_commit_msg=$(git rev-list --format="%s" -1 HEAD -- $file | tail -n 1)
if [ -z "$previous_commit" ]; then
echo "$file NEW"
else
echo "$file $previous_commit"
git commit -m "fixup! $previous_commit_msg" -m "$file $previous_commit"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment