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

后端 未结 5 575
攒了一身酷
攒了一身酷 2020-12-23 02:28

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 s

相关标签:
5条回答
  • 2020-12-23 03:20

    git ls-files -o --exclude-standard

    Every path in your worktree that isn't staged (-o) and won't be ignored by git add (--exclude-standard).

    0 讨论(0)
  • 2020-12-23 03:23

    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.

    0 讨论(0)
  • 2020-12-23 03:29

    use git command git ls-files -o to list untracked file

    instead -o use -c --cached Show cached files in the output (default)

    -d --deleted Show deleted files in the output

    -m --modified Show modified files in the output

    0 讨论(0)
  • 2020-12-23 03:31

    How about putting a .gitignore file in your sub directories instead along the line of

    # Ignore everything in this directory
    *
    # Except these file
    !.gitignore
    !file1
    !file2
    !file3
    
    0 讨论(0)
  • 2020-12-23 03:33

    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).

    0 讨论(0)
提交回复
热议问题