Search code examples
git

How do I list all files with a specific extension in my git repository?


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?


Solution

  • Try the following command:

    git ls-files '*.rb'