I have many changed files and would like to stash only some of the modified files.
As an example, my repository looks something like:
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: main.cpp
modified: MyClass.h
modified: MyClass.cpp
And I would like to stash MyClass.h
and MyClass.cpp
only.
I found this question but the accepted answer appears to be wrong and the most voted answer requires each hunk/file to be interactively added.
Is there an easy way to stash a specific set of files? Preferably in a single command without having to interactively select files one by one or stage/unstage things.