Well, as the title says, is there an option I can set in git, that will make it automatically include untracked files when I execute git stash
, so I don't have to remember the -u
option.
Alternately, after I created a stash, and I discover that I forgot to include untracked files, can I amend those to the stash?
Stash Untracked Files Using “git add” You have to add the untracked files of the repository by using the “git add” command and run the “git stash” command to save the untracked file and clean the current directory for working by removing the untracked file from the repository folder.
By default, the git stash push and save commands will only save files that were either added to the Git index or are part of the Git commit message history. If a developer adds a file to the local working tree but it remains untracked by the Git framework, the file won't be added.
When the pop command runs, it's expected that files from the stash will overwrite the contents of the files in the local working tree, and the updated files will be staged in the git index. But if a git stash pop conflict arises, then the problematic files won't be added to the index.
In short, tracked files are files that Git knows about. Untracked files are everything else — any files in your working directory that were not in your last snapshot and are not in your staging area.
I failed to find a configuration option to do this in the git-config
manual page ($ man git-config
, or $ git config --help
, or read it online), but you can get away easily using an alias:
$ git config alias.stashall 'stash -u'
$ git stashall
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