I would like to use this workflow:
Is there a way to do step 2?
Example:
git init echo one >file git add file git commit echo two >>file git add file echo three >>file git stash push test git commit git stash pop
Stage all your files that you need to stash. Run git stash --keep-index . This command will create a stash with ALL of your changes (staged and unstaged), but will leave the staged changes in your working directory (still in state staged). Now your "good stash" has ONLY staged files.
Stashing your work The git stash command takes your uncommitted changes (both staged and unstaged), saves them away for later use, and then reverts them from your working copy.
Git doesn't have a command that stashes only your unstaged changes. Git does, however, let you specify which files you want to stash. If you only want to stash specific changes in those files, add the --patch option. The --include-untracked option lets you stash untracked files.
git stash push
has an option --keep-index
that does exactly what you need.
So, run git stash push --keep-index
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With