Git stash

From NovaOrdis Knowledge Base
Revision as of 02:36, 27 August 2020 by Ovidiu (talk | contribs)
Jump to navigation Jump to search

Internal

Overview

Stash the changes in a dirty working directory away. The command saves the local modifications away and reverts the working directory to match the HEAD commit.

To stash away changes:

git stash
Saved working directory and index state WIP on branch-name: 0d0178916ee commit comment 

The modifications stashed away can be listed with:

git stash list

To see the files affected by the stash:

git stash show

They can be restored, potentially in top of a different commit, with:

git stash apply

Without an argument, "apply" applies the content set at the top of the stack (the latest).

Note that the stash state stays on the stack - to remove it:

git stash drop

To remove an arbitrary stash state:

git stash drop <number>


This clears all stash entries:

git stash clear