Stash Please

Susan Joshi
2 min readJan 30, 2017

--

Most of the time, we spend working on two or more features side by side. Similarly, while working on a feature, some bug appears on the production. In these situations, we have to set priority on which job to finish up first. On the later case, the bug on the production will have higher priority to solve rather than continuing on the current story.

http://gph.is/1AdRN9J

In some cases, we might be focused or in an intense session where we are not ready to commit the recent changes and we have to switch context on the same project due to some bug on the production. Likewise, we want to work on two features simultaneously and do not want to accidentally commit wrong files. So, what would you do to save the current changes in these states?

We use git for my day to day projects. git has handy feature that can help us in this context. We can try following command:

$ git stash

Using this command we can save the current state of the working area and revert ourselves back to the clean working state. Sometimes, there are new files, and we would like a clean working directory. In this case we can simply use:

$ git stash -u

git stash [-u | - -include-untracked] will empower us to stash the untracked files as well. Now we can change our branch and start working on the bug or other job.

If we have finished and want to continue working on previous task, we can do

$ git stash pop

Now, we can continue our path to enlightenment :)

If anybody wants to know more, they can go to git stash reference guide.

--

--