Stashing
Use "git stash" when you want to record the current state of the working directory and the index, but want to go back to a clean working directory. The command saves your local modifications away and reverts the working directory to match the HEAD commit.
- git stash save [msg]
-
Save your local modifications to a new stash, and run "git reset --hard" to revert them. This is the default action when no subcommand is given. If msg is not explicitly given, then it defaults to "WIP on branch" where "branch" is the current branch name.
- git stash list
-
List all current stashes.
- git stash apply [stash]
-
Restore the changes recorded in the stash on top of the current working tree
state. When no stash is given, applies the latest one (stash@{0}). The working directory
must match the index.
- git stash pop [stash]
-
Remove a single stashed state from the stash list and apply on top of the
current working tree state. When no stash is given, the latest one (stash@{0}) is assumed.
- git stash clear
-
Remove all the stashed states.
- git stash drop [stash]
-
Remove a single stashed state from the stash list. When no stash is given, it removes the latest one. i.e. stash@{0}.
- git stash branch new-branch [stash]
-
Creates and checks out a new branch named new-branch starting from the commit
at which the stash was originally created, applies the changes recorded in
stash to the new working tree and index, then drops the stash if that
completes successfully. When no stash is given, applies the latest one.