Selectively stash files and code hunks with git

28.Mar.2018

One of the cool features of git is that it lets you stash local changes while working with the repository. This will save the changes in a separate stack and will yield a clean working directory:

When needed, these changes can be reintroduced to the working directory by calling the apply command:

Finally, an even cooler feature of the stash command is that can allow you to stash only a subset of the changes in the working directory. You can choose which files and which code hunks should be stashed with the following command:

Stash away!