Skip to content

Instantly share code, notes, and snippets.

@ericwoodruff
Created December 8, 2013 19:50
Show Gist options
  • Save ericwoodruff/7862982 to your computer and use it in GitHub Desktop.
Save ericwoodruff/7862982 to your computer and use it in GitHub Desktop.
Inverting git index
[alias]
swaplast = !git tag _invert && git reset --hard HEAD~2 && git cherry-pick _invert _invert~1 && git tag -d _invert
invertindex = !git commit -m tmp1 && git add -A && git commit -m tmp2 && git swaplast && git reset HEAD~1 && git reset HEAD~1 --soft
@u01jmg3
Copy link

u01jmg3 commented Jul 8, 2016

Thanks for this - very helpful

Just have a few queries:

  1. Is there any way of checking that at least one hunk is staged and one hunk is unstaged before allowing this alias to run?
  2. Also, I have created a custom action in SourceTree to run this alias; is there any way of checking that the current repo is using Git (rather than Mercurial) before allowing this alias to run?

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