Showing Untracked Files In Status After Creating New Directories In Git
Overview
If you create a directory in a repo and start adding files, when you check the repository status with git status, by default it will just list the new directory and not its files.
Using a special parameter in git status
we can see all the files
in the new directory we want to stage.
Seeing untracked files
git status
has the untracked-files
switch where we select which
files to see each time we execute git status
.
The mode parameter is used to specify the handling of untracked files. It is optional: it defaults to all, and if specified, it must be stuck to the option (e.g. -uno, but not -u no). The possible options are: -no - Show no untracked files. -normal - Shows untracked files and directories. -all - Also shows individual files in untracked directories.
Using the --untracked-files=all
we see all the files in new
directories.
I will create a new directory with some untracked files to see its behaviour:
$ mkdir new_feature $ touch new_feature/feature_a $ touch new_feature/feature_b $ git status On branch master Initial commit Untracked files: (use "git add <file>..." to include in what will be committed) new_feature/ nothing added to commit but untracked files present (use "git add" to track)
Showing untracked files
Using git status untracked-files=all
:
$ git status --untracked-files=all
On branch master
Initial commit
Untracked files:
(use "git add <file>..." to include in what will be committed)
new_feature/feature_a
new_feature/feature_b
nothing added to commit but untracked files present (use "git add" to track)
Now we can stage new files directly.
Setting as the default behaviour
To save this setting, we use git config --global status.showuntrackedfiles all
so it will add the following to git
configuration in ~/.config
:
[status]
showuntrackedfiles = all
Or we can just add the above code manually to ~/.config
.
References
- Git status documentation https://git-scm.com/docs/git-status#git-status--ultmodegt
- Choose files to stage of a new directory with magit in Emacs
- Creating a git server from a git repoJuly 1, 2016
- Showing Untracked Files In Status After Creating New Directories In Git
Articles
Except as otherwise noted, the content of this page is licensed under CC BY-NC-ND 4.0 . Terms and Policy.
Powered by SimpleIT Hugo Theme
·