+4 votes
1 view
in Devops and Agile by (28.1k 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 (48k 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 (28.4k 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
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...