Skip to content

Instantly share code, notes, and snippets.

@Mikulas
Created May 2, 2017 11:06
Show Gist options
  • Save Mikulas/84efdbdd57f68f8dc69bdb5978fd7371 to your computer and use it in GitHub Desktop.
Save Mikulas/84efdbdd57f68f8dc69bdb5978fd7371 to your computer and use it in GitHub Desktop.
#!/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
@Mikulas
Copy link
Author

Mikulas commented May 2, 2017

In Git interactive rebase

# ...
pick 9923cc6 prepare LeoExpress\Connection type
exec git split-fixups
pick 7842763 ScheduleEntryList::fromPrices
# ...

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