Git Stash

Git stash is important when a user wants to temporarily save changes on their working directory. Suppose the user is working on some code on their working directory and they are not ready to commit the changes yet. Git stash is the command to use.

Git Stash at a Glance

Image Source:

To stash your changes run the command;

git stash

By default git stash can only stash changes to existing files and not new untracked files. To stash your entire directory including untracked files, use the below command.

git stash --include-untracked

Git Stash Untracked Files

To check the list of all your stashes use

git stash list
Git Stash List

To check the details of a particular stash

git stash show -p stash@{1}
Show Details of a Particular Stash

Suppose, one does not have need for a particular stash we can use the below command to delete a stash.

git stash drop stash@{0}
Drop a Particular Stash

To get rid of all your stashes use the command:

git stash clear
Clear all Stashes

To retrieve stash changes of a particular change, use the below command. Once retrieved the reader can now add and commit the changes.

git stash pop stash@{0}
Git Stash Pop

Important Links:

One thought on “Git Stash

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s