Stash changes for later
Use git stash
when you want to change to a different branch, and you want to store changes that are not ready to be
committed.
-
To stash uncommitted changes without a message:
git stash
-
To stash uncommitted changes with a message:
git stash save "this is a message to display on the list"
-
To retrieve changes from the stash and apply them to your branch:
git stash apply
-
To apply a specific change from the stash to your branch:
git stash apply stash@{3}
-
To see all of the changes in the stash:
git stash list
-
To see a list of changes in that stash with more information:
git stash list --stat
-
To delete the most recently stashed change from the stash:
git stash drop
-
To delete a specific change from the stash:
git stash drop <name>
-
To delete all changes from the stash:
git stash clear
-
To apply the most recently stashed change and delete it from the stash:
git stash pop
If you make a lot of changes after stashing your changes, conflicts might occur when you apply these previous changes back to your branch. You must resolve these conflicts before the changes can be applied from the stash.
Git stash sample workflow
To try using Git stashing yourself:
-
Modify a file in a Git repository.
-
Stash the modification:
git stash save "Saving changes from edit this file"
-
View the stash list:
git stash list
-
Confirm there are no pending changes:
git status
-
Apply the stashed changes and drop the change from the stash:
git stash pop
-
View stash list to confirm that the change was removed:
git stash list
Docs
Edit this page to fix an error or add an improvement in a merge request.
Create an issue to suggest an improvement to this page.
Product
Create an issue if there's something you don't like about this feature.
Propose functionality by submitting a feature request.
Feature availability and product trials
View pricing to see all GitLab tiers and features, or to upgrade.
Try GitLab for free with access to all features for 30 days.
Get help
If you didn't find what you were looking for, search the docs.
If you want help with something specific and could use community support, post on the GitLab forum.
For problems setting up or using this feature (depending on your GitLab subscription).
Request support