Imagine that to run an app locally, you need to change a configuration file. No matter what branch you are currently on, this configuration file will need to remain the same. Let's call it
Now, you're working on a topic branch
feature-a and have 2 edited files (
a.css). You get interrupted and need to switch to topic branch
Of course, you need to stash your changes. Unfortunately, that means all 3 changed files will get stashed. Once you're on
feature-b, you'll need to edit
config.js again to run the app locally. What a pain!
Fortunately, there is an easier way!
git stash push -m stash_message_goes_here a.html a.css
This command will stash only the files
config.js in your working directory. Now, you can checkout
feature-b and run the app locally.