Home > Software engineering >  Command to list files in the working directory of GIT
Command to list files in the working directory of GIT

Time:04-24

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!

CodePudding user response:

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.

CodePudding user response:

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.

  •  Tags:  
  • git
  • Related