Skip to content

Instantly share code, notes, and snippets.

@stephanebachelier
Forked from eddiemoya/git-flip-last.sh
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephanebachelier/8803647 to your computer and use it in GitHub Desktop.
Save stephanebachelier/8803647 to your computer and use it in GitHub Desktop.
fix typo
#!/bin/bash
branch=$(git name-rev --name-only HEAD)
git rebase --onto HEAD~2 HEAD~1 HEAD
git cherry-pick ORIG_HEAD~1
git update-ref refs/heads/$branch $(git rev-parse HEAD)
git checkout --quiet $branch
# Instead of creating an independant bash script with the code above,
# consider simply creating a git alias using the command below.
#
# USAGE: git flip-last
git config --global alias.flip-last "!branch=$(git name-rev --name-only HEAD); git rebase --quiet --onto HEAD~2 HEAD~1 HEAD; git cherry-pick ORIG_HEAD~1; git update-ref refs/heads/$branch $(git rev-parse HEAD); git checkout --quiet $branch"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment