Temporary saving of work using git stash
Đặng Đình Sáng
Posted on July 3, 2024
Introduction
git stash
to temporarily save changes you are working on.
How to use it
Save changes temporarily
git stash
This saves the changes in your current working directory to a stash, leaving your working directory clean.
Apply the stash
git stash apply
This applies the latest stash to the current working directory. The stash remains in place and can be reapplied.
Apply and remove the stash
git stash pop
This will apply the latest stash and remove it from the stash at the same time.
Display a list of stashes
git stash list
This will display a list of saved stashes.
Apply a specific stash
git stash apply stash@{1}
If multiple stashes exist, you can apply a specific stash by using the format stash@{n}.
Drop a specific stash
git stash drop stash@{1}
To drop a specific stash, use the following command.
This will remove the stash at stash@{1}.
Conclusion
A git stash is useful for temporarily storing changes you are working on so you can do other work or switch branches.
Posted on July 3, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.