File tree Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
1010
1111For a steady stream of TILs, [ sign up for my newsletter] ( https://tinyletter.com/jbranchaud ) .
1212
13- _ 1097 TILs and counting..._
13+ _ 1098 TILs and counting..._
1414
1515---
1616
@@ -290,6 +290,7 @@ _1097 TILs and counting..._
290290- [ Skip Pre-Commit Hooks] ( git/skip-pre-commit-hooks.md )
291291- [ Staging Changes Within Vim] ( git/staging-changes-within-vim.md )
292292- [ Staging Stashes Interactively] ( git/staging-stashes-interactively.md )
293+ - [ Stash A Single Untracked File] ( git/stash-a-single-untracked-file.md )
293294- [ Stash Everything] ( git/stash-everything.md )
294295- [ Stashing Only Unstaged Changes] ( git/stashing-only-unstaged-changes.md )
295296- [ Stashing Untracked Files] ( git/stashing-untracked-files.md )
Original file line number Diff line number Diff line change 1+ # Stash A Single Untracked File
2+
3+ If you want to stash everything in your work tree and untracked files, you can
4+ run:
5+
6+ ``` bash
7+ $ git stash -u
8+ ```
9+
10+ If you want a bit more control over what gets stashed from the work tree, you
11+ can interactively stash with ` --patch ` (or ` -p ` ):
12+
13+ ``` bash
14+ $ git stash -p
15+ ```
16+
17+ Unfortunately, the two don't work together.
18+
19+ ``` bash
20+ $ git stash -u -p
21+ Can' t use --patch and --include-untracked or --all at the same time
22+ ```
23+
24+ So, if you' d like to stash a specific untracked file, you can instead formulate
25+ a command like the following:
26+
27+ ` ` ` bash
28+ $ git stash -u -- < name-of-untracked-file>
29+ ` ` `
30+
31+ This will stash just the specified untracked file and leave the rest of them as
32+ they are.
33+
34+ I found this useful when trying to test the setup of a new library. There was
35+ an extra new file that I didn' t think I needed. Stashing it temporarily gets it
36+ out of the way without losing it.
You can’t perform that action at this time.
0 commit comments