Skip to content

Instantly share code, notes, and snippets.

@induratized
Last active July 3, 2025 06:27
Show Gist options
  • Save induratized/a9b8039adc58bedf9b250b29d9b73ce1 to your computer and use it in GitHub Desktop.
Save induratized/a9b8039adc58bedf9b250b29d9b73ce1 to your computer and use it in GitHub Desktop.
how to add unstaged + untracked file in git stash

To stash only unstaged + untracked files, while keeping staged changes intact, you can use:

git stash push --include-untracked --keep-index

βœ… Explanation:

  • --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

πŸ” To reapply the stash later:

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment