Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

git ls-files --others

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

like image 795
Leo Alekseyev Avatar asked Apr 21 '11 07:04

Leo Alekseyev


2 Answers

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.

like image 57
VonC Avatar answered Sep 28 '22 10:09

VonC


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.

like image 44
Mark Longair Avatar answered Sep 28 '22 09:09

Mark Longair