Displaying the file information

While git ls-tree can give information about tree objects in the repository, it can't be used to display information about the index and working area. The git ls-files command can do this, and we will explore this next.

Getting ready

Again, we'll use the data-model repository from the previous example.

How to do it...

For specific file information, we can use the ls-files command to get information about files in the working tree and the staging area. By default, git ls-files will show the files in the staging area, as shown in the following command:

$ git ls-files
README.md
a_sub_directory/readme
another-file.txt
cat-me.txt
hello_world.c

Note this includes all files in the staging area (the tree state at the latest ...

Get Git: Mastering Version Control now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.