To stash only unstaged + untracked files, while keeping staged changes intact, you can use:
git stash push --include-untracked --keep-index-
--keep-index: Leaves your staged files untouched. -
--include-untracked: Includes untracked files (e.g. new files you've created but haven't added to Git yet) in the stash. -
Stashes only:
- Unstaged changes to tracked files
- Untracked files
git stash pop
β οΈ This will reapply both the unstaged changes and the untracked files that were stashed.
Let me know if you also want to stash ignored files (.gitignored) β that would use --all.