Skip to content

Instantly share code, notes, and snippets.

@mochja
Created March 3, 2016 11:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mochja/ea262354067efa2a1ce2 to your computer and use it in GitHub Desktop.
Save mochja/ea262354067efa2a1ce2 to your computer and use it in GitHub Desktop.
Spread changes to last file modification
#!/bin/bash
for f in $(git status --porcelain); do
if [ -f "$f" ]; then
hash=$(git log -n1 --pretty=%H "$f")
if [ ! -z "$hash" ]; then
git add "$f" && git commit --fixup "$hash"
fi;
fi
done
echo "Run `git rebase -i <branch> --autosquash` to apply the changes."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment