Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I have "git stash" to automatically include untracked files by default?

Tags:

git

git-stash

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?

like image 768
Pete Avatar asked Dec 02 '13 10:12

Pete


People also ask

How do I keep my git files untracked?

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.

Does git stash save added files?

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.

Does git stash pop overwrite changes?

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.

What is the difference between tracked and untracked files in git?

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.


1 Answers

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
like image 183
kostix Avatar answered Sep 28 '22 01:09

kostix