Say I start a git repository in a folder, and I have several subdirectories in it.
I have several globbing patterns .gitignore
to exclude files in the subdirectories. However, when I do git status
before I stage anything, git status only shows the names of the subfolders that will be added, without being specific about which files in each subdirectory will be added (staged) if I do git add .
.
Interestingly though, git status
is explicit about the files that will be committed after I stage files with git add .
.
Is there anyway to ask git status
to be explicit about files for the files that would be staged?
The easiest way to add all files to your Git repository is to use the “git add” command followed by the “-A” option for “all”. In this case, the new (or untracked), deleted and modified files will be added to your Git staging area. We also say that they will be staged.
The git status command displays the state of the working directory and the staging area. It lets you see which changes have been staged, which haven't, and which files aren't being tracked by Git. Status output does not show you any information regarding the committed project history.
To check the status, open the git bash, and run the status command on your desired directory. It will run as follows: $ git status.
Git Status Command The git status is another must-know command that returns information about the current state of the repository. For e.g. a list of files changed, list of tracked changes on staging, untracked changes on local, and information about current branch & commits.
Try:
git status -u
or the long form:
git status --untracked-files
which will show individual files in untracked directories.
Here's the detailed description of -u
option from git-status man page:
-u[<mode>]
--untracked-files[=<mode>]
Show untracked files.
The mode parameter is optional (defaults to
all
), and is used to specify the handling of untracked files; when-u
is not used, the default isnormal
, i.e. show untracked files and directories.The possible options are:
no
- Show no untracked filesnormal
- Shows untracked files and directoriesall
- Also shows individual files in untracked directories.The default can be changed using the
status.showUntrackedFiles
configuration variable documented in git-config(1).
You can simply use
git add --dry-run .
in the root of your repository which gives you a list of any file in any sub directory that would be added while considering .gitignore
.
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