Privacy Policy
© 2025 linux101.dev

Git: Stash changes

The git stash command is used to temporarily save changes in your working directory that are not yet ready to be committed. This allows you to switch branches or perform other tasks without losing your uncommitted changes. The stashed changes are stored in a stack, allowing you to apply or drop them later.

Stash Changes

Stash current changes

git stash

Stashes the current changes in your working directory and staging area.

Stash with message

git stash save "message"

Stashes the current changes with a descriptive message.

View Stashed Changes

List stashed changes

git stash list

Displays a list of all stashed changes along with their identifiers and messages.

Apply Stashed Changes

Apply the most recent stash

git stash apply

Applies the most recent stashed changes to your working directory without removing them from the stash stack.

Apply a specific stash

git stash apply stash@{n}

Applies a specific stash identified by its index (replace n with the appropriate number from git stash list).

Apply and drop the most recent stash

git stash pop

Applies the most recent stashed changes and removes them from the stash stack.

Apply and drop a specific stash

git stash pop stash@{n}

Applies a specific stash and removes it from the stash stack (replace n with the appropriate number from git stash list).

Manage Stashed Changes

Drop a specific stash

git stash drop stash@{n}

Removes a specific stash from the stash stack without applying it (replace n with the appropriate number from git stash list).

Clear all stashes

git stash clear

Removes all stashed changes from the stash stack.

Show changes in a specific stash

git stash show -p stash@{n}

Displays the changes contained in a specific stash (replace n with the appropriate number from git stash list).