Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
+4 votes
4 views
in DevOps and Agile by (29.3k points)
edited by

Using command-line git, how can I make git show a list of the files that are being tracked in the repository?

2 Answers

+3 votes
by (50.2k points)

To list all the files currently being tracked under the branch master using: 

git ls-tree -r master --name-only

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.

+3 votes
by (27.5k points)

To show all of the tracked files that have been committed (on the current branch), use

git ls-tree --full-tree --name-only -r HEAD

  • --full-tree makes the command run as if you were in the repo's root directory.
  • -r recurses into subdirectories. Combined with --full-tree, this gives you all committed, tracked files.
  • --name-only removes SHA / permission info for when you just want the file paths.
  • HEAD specifies which branch you want the list of tracked, committed files for. You can change this to master or any other branch name, but HEAD is the commit you have checked out right now

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...