My git repository tracks many kinds of files, such as Ruby files, YAML files, and Markdown files. I want a list of all Ruby files in my repo, but I can't use find -type f -name '*.rb'
because I also have a build directory that is not tracked by git but contains lots of ruby files. How can I list only those *.rb
files that are tracked by git?
Add a comment
|
1 Answer
Try the following command:
git ls-files '*.rb'
-
3
-
Thank you, @PA. this usage wasn't clear from the git-ls-files man page, and I couldn't find any mention of using arguments to
git ls-files
like this on SO. Oct 19, 2015 at 22:21 -
-
2@PA. - that doesn't work. Without the single quotes, the shell expands the glob pattern. Oct 20, 2015 at 22:11
-
1