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 stashStashes 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 listDisplays a list of all stashed changes along with their identifiers and messages.
Apply Stashed Changes
Apply the most recent stash
git stash applyApplies 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 popApplies 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 clearRemoves 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).