Stashing Changes
Sometimes you’re in the middle of work but need to switch branches urgently. You don’t want to commit incomplete code. Git stash lets you temporarily save your changes and clean your working directory.
What Is Stash?
Stashing takes your uncommitted changes (both staged and unstaged), saves them on a stack, and reverts your working directory to the last commit. You can later reapply the stashed changes.
Stashing Your Changes
To save your current changes:
git stashYou can add a message for clarity:git stash push -m "WIP: login feature"Listing Stashes
See all stashed entries:
git stash listOutput shows something like: stash@{0}: On main: WIP: login featureApplying Stashed Changes
To apply the most recent stash and keep it in the stash list:
git stash applyTo apply and also remove it from the stash list:git stash popYou can apply a specific stash: git stash apply stash@{1}Dropping Stashes
To remove a stash without applying it:
git stash drop stash@{0}To clear all stashes:git stash clearTwo Minute Drill
git stashsaves uncommitted changes and cleans the working directory.- View stashes with
git stash list. git stash applyreapplies changes but keeps the stash.git stash popreapplies and removes the stash.- Drop a stash with
git stash drop.
Need more clarification?
Drop us an email at career@quipoinfotech.com
