How does one show untracked files in current directory only (ignoring subdirectories)?

后端 未结 3 1441
無奈伤痛
無奈伤痛 2021-02-05 20:42
git ls-files --others

goes down the directory tree. Is there an easy way to show untracked files only in the current directory?

相关标签:
3条回答
  • 2021-02-05 20:52

    If the current directory is the top of the repo, you can do this

    git ls-files -iox "/*"
    
    0 讨论(0)
  • 2021-02-05 20:55

    Use the exclude pattern of ls-files:

     # on Windows, with msysgit
     git ls-files --others -x */*
    
     # on Unix (Cygwin or Ubuntu), quotes are necessary around the pattern
     git ls-files --others -x "*/*"
    

    From the man page:

    -x <pattern>
    --exclude=<pattern>
    

    Skip untracked files matching pattern. Note that pattern is a shell wildcard pattern.

    0 讨论(0)
  • 2021-02-05 21:18

    I don't think there's an option to git ls-files that has that effect, but you could always just do:

    git ls-files --other | grep -v /
    

    ... to just list the untracked files in the current directory.

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