O'Reilly logo

Git: Mastering Version Control by Jakub Narębski, Rasmus Voss, Aske Olsson, Ferdinando Santacroce

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using git stash

In this example, we explore the git stash command and learn how we can use it to quickly put away uncommitted changes and retrieve these again. This can be useful when being interrupted with an urgent task and you are not yet ready to commit the work you currently have in your working directory. With the git stash command, you save the state of your current working directory with/without a staging area and restore a clean state of the working tree.

Getting ready

In this example, we'll use the cookbook-tips-tricks repository. We'll use the master branch, but before we are ready to try the stash command, we need to create some changes in the working directory and the staging area:

$ git clone https://github.com/dvaske/cookbook-tips-tricks.git ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required