Skip to content

Instantly share code, notes, and snippets.

@LisannaAtHome
Created January 26, 2018 06:27
Show Gist options
  • Save LisannaAtHome/269574f53f7bfd71a9a3fdd418c71899 to your computer and use it in GitHub Desktop.
Save LisannaAtHome/269574f53f7bfd71a9a3fdd418c71899 to your computer and use it in GitHub Desktop.
Extracts all the changes from your HEAD commit and unstages them, leaving the commit message in-place (albeit with a different sha, of course), so it's easier to go back and fix the commit with visual diff -enabled editors (since the changes will show up as unstaged, and will usually be colorized).
#!/usr/bin/env bash
git log --format=%B -n 1 HEAD > ._GIT_EXTRACT_MSG && git reset --soft HEAD^ && git reset HEAD && git commit --allow-empty -F ._GIT_EXTRACT_MSG && rm ._GIT_EXTRACT_MSG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment