Created
May 2, 2017 11:06
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
#!/usr/bin/env bash | |
set -euo pipefail | |
IFS=$'\n\t' | |
git reset . | |
if [[ -e ".git/rebase-merge/interactive" ]]; then | |
git reset HEAD~1 | |
fi | |
git diff --name-only \ | |
| while read FILE; do | |
echo "$FILE" | |
CHANGED_IN="$(git log --pretty='%H' origin/master...HEAD -- "$FILE")" | |
if [[ -z "$CHANGED_IN" ]]; then | |
echo "$FILE is first changed in this commit, no commit to fixup found" | |
fi | |
for COMMIT in $CHANGED_IN; do | |
set -x | |
git add "$FILE" | |
git commit --fixup "$COMMIT" | |
set +x | |
break | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In Git interactive rebase