Answered
How can I get a list of all the files in my Git repository on my local machine? Is there a way to do this via the command line?
If it matters, my machine is a Macbook Pro.
Thanks in advance!
Try this Git command:
git ls-files
That will give you full list of each file in your Git repository, including ones that are currently staged.
Git documentation: https://git-scm.com/docs/git-ls-files.
git ls-tree --full-tree -r --name-only HEAD
This will list all the files that have been committed to the repo.
--full-tree
: tells Git to include the entire directory. As if the command was ran from your project root.-r
: tells Git to recursively go through each directory in the repo.--name-only
: tells Git to only include the file paths.HEAD
: then name of the branch you want information for. This can be changed to master
, develop
, etc.List the files for a specific branch:
git ls-tree -r master --name-only
Replace master
with the name of the branch you want to examine.
This will list all the files that have existed in your repo:
git log --pretty=format: --name-status | cut -f2- | sort -u