Skip to content

Instantly share code, notes, and snippets.

@thefrench77
Created January 13, 2017 05:45
Show Gist options
  • Select an option

  • Save thefrench77/8f0ef6b9c9eeb9f5ec5cd7dc721a22fa to your computer and use it in GitHub Desktop.

Select an option

Save thefrench77/8f0ef6b9c9eeb9f5ec5cd7dc721a22fa to your computer and use it in GitHub Desktop.
Interrupted workflow
Suppose you are interrupted by an urgent fix request while you are in the middle of a large change. The files in your working tree are not in any shape to be committed yet, but you need to get to the other branch for a quick bugfix.
$ git checkout feature ;# you were working in "feature" branch and
$ work work work ;# got interrupted
$ git commit -a -m "snapshot WIP" (1)
$ git checkout master
$ fix fix fix
$ git commit ;# commit with real log
$ git checkout feature
$ git reset --soft HEAD^ ;# go back to WIP state (2)
$ git reset (3)
This commit will get blown away so a throw-away log message is OK.
This removes the WIP commit from the commit history, and sets your working tree to the state just before you made that snapshot.
At this point the index file still has all the WIP changes you committed as snapshot WIP. This updates the index to show your WIP files as uncommitted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment