Skip to content

Instantly share code, notes, and snippets.

@KronicDeth
Created July 31, 2015 20:10
Show Gist options
  • Save KronicDeth/ff0697acb574d69f0e2a to your computer and use it in GitHub Desktop.
Save KronicDeth/ff0697acb574d69f0e2a to your computer and use it in GitHub Desktop.
Breaking up a working tree into multiple commits

Breaking up a working tree into multiple commits

If you ever have more than one commit's worth of changes in your git work tree, and you're trying to separate the commits:

  1. git reset HEAD to unstage everything
  2. Stage pieces with git add --patch
  3. Remove everything unstaged or untracked (so new file) with git stash -k -u
  4. rake spec to ensure that staged pieces pass specs on their own
  5. git commit
  6. git stash pop to restore the stash from (2)
  7. Goto (1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment