Posted over 8 years ago. Visible to the public. Repeats.

Use the Git stash without shooting yourself in the foot

The Git stash does not work like a one-slot clipboard and you might shoot yourself in the foot if you pretend otherwise.

In particular git stash apply does not remove the stashed changes from the stash. That means you will probably apply the wrong stash when you do git stash apply after a future stashing.

To keep your stash clean, you can use

Copy
git stash pop

instead.

Another way to look at it:

Copy
git stash pop

is the same as

Copy
git stash apply && git stash drop

Notice: In case of a conflict git will not pop the changes, you will need to drop the uppermost stash, if you merged successfully:

Copy
git stash drop

Once an application no longer requires constant development, it needs periodic maintenance for stable and secure operation. makandra offers monthly maintenance contracts that let you focus on your business while we make sure the lights stay on.

Owner of this card:

Avatar
Tobias Kraze
Last edit:
over 2 years ago
by Pascal Schmid
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Tobias Kraze to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more