Read more

Use the Git stash without shooting yourself in the foot

Tobias Kraze
September 01, 2010Software engineer at makandra GmbH

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

Illustration UI/UX Design

UI/UX Design by makandra brand

We make sure that your target audience has the best possible experience with your digital product. You get:

  • Design tailored to your audience
  • Proven processes customized to your needs
  • An expert team of experienced designers
Read more Show archive.org snapshot

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

git stash pop

instead.

Another way to look at it:

git stash pop 

is the same as

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:

git stash drop
Posted by Tobias Kraze to makandra dev (2010-09-01 12:21)