Skip to content

Instantly share code, notes, and snippets.

@nachof
Created January 14, 2010 19:50
Show Gist options
  • Save nachof/277438 to your computer and use it in GitHub Desktop.
Save nachof/277438 to your computer and use it in GitHub Desktop.
#!/bin/sh
# It will only work if there is something staged and something unstaged, but it's just a proof of concept :)
TARGET=$1
git stash --keep-index
git stash
ORIGINAL=$(git show -s --pretty=%H)
git reset --hard $TARGET
git stash pop
git commit -a --amend
for h in $(git log $TARGET..$ORIGINAL --reverse --pretty=%H); do git cherry-pick $h; done
git stash pop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment