Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git status -> Show files that will be added (staged) in subdirectories

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?

like image 923
Amelio Vazquez-Reina Avatar asked Oct 01 '12 22:10

Amelio Vazquez-Reina


People also ask

How do you git add all staged files?

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.

What information does git status show?

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.

How do I see my git status?

To check the status, open the git bash, and run the status command on your desired directory. It will run as follows: $ git status.

Which command is used to track the staged files?

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.


2 Answers

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 is normal, i.e. show untracked files and directories.

The possible options are:

  • no - Show no untracked files
  • normal - Shows untracked files and directories
  • all - Also shows individual files in untracked directories.

The default can be changed using the status.showUntrackedFiles configuration variable documented in git-config(1).

like image 60
Penghe Geng Avatar answered Sep 30 '22 01:09

Penghe Geng


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.

like image 43
cweigel Avatar answered Sep 30 '22 00:09

cweigel