简体   繁体   中英

Command to list files in the working directory of GIT

Is there any command to list files in the working directory of git?

I know we have commands for the below:

  1. To list files in branch (committed): git ls-tree -r --name-only HEAD
  2. To list files in staging directory: git ls-files -s

But not able to find command to list files in the working directory.

Thanks!

The working directory is the place you're working in and where your files are actually spawned when you check out a given revision. So you want to check them out with your regular operating system command. That is, either dir or ls from cmd or an Unix shell, or the common file explorer.

That would be

ls -R

Since this is the working directory, this is not a Git matter; just talk to the shell and ask it for the list.

Observe that, in the form I have given the command, the .git folder itself (the repo) is not listed, as it is "invisible". Which is good!

The same thing is true when you want to know the contents of a file. To learn what's in myfile.txt in commit abcdef123 , you would say git show abcdef123:myfile.txt . But to learn what's in myfile.txt in the working directory, you don't talk to Git at all; you would say cat myfile.txt .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM