Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

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?

like image 646
jayhendren Avatar asked Oct 19 '15 18:10

jayhendren


People also ask

How do I list files in git?

This command will list the files that are being tracked currently. If you want a list of files that ever existed use: git log --pretty=format: --name-only --diff-filter=A | sort - | sed '/^$/d'This command will list all the files including deleted files.

What is ls command in git?

git directory with the command ls -a . The ls command lists the current directory contents and by default will not show hidden files. If you pass it the -a flag, it will display hidden files. You can navigate into the . git directory like any other normal directory.

What's a shortcut to add all the files that you have in git?

Add All Files using Git Add. The easiest way to add all files to your Git repository is to use the “git add” command followed by the “-A” option for “all”. In this case, the new (or untracked), deleted and modified files will be added to your Git staging area. We also say that they will be staged.


1 Answers

Try the following command:

git ls-files '*.rb'
like image 198
jayhendren Avatar answered Oct 11 '22 01:10

jayhendren