How can you view all the files in a directory using git?

The command “git ls-files” can be used to view all tracked files in a Git repository.

Navigate to the target directory in the terminal, and then execute the following command:

git ls-files

This will list all tracked files in the current directory and its subdirectories. To display more detailed information, you can add the -s parameter.

git ls-files -s

This will display the permission mode and SHA-1 hash value for each file.

Also, if you only want to view files under a specific directory, you can add the directory path after the command.

git ls-files <目录路径>

For example, to view all the files in the src directory, you can execute the following command:

git ls-files src/
广告
Closing in 10 seconds
bannerAds