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?
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.
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.
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.
Try the following command:
git ls-files '*.rb'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With