问题
How can I check files in current directory, from git bash?
Like command dir
, in Windows cmd
?
I found a command git ls-files
, but it's work only with git repository files. But if I navegate through drive C:\, and want to see files in current directory, how can I do that in git bash?
回答1:
The git bash is basically a Unix shell, therefore you can list current files and directories with the ls
command
You can also use ls -a
to show hidden files and folders.
Since it is a Unix shell, you can make an alias called dir
in a .bashrc file. It's handy when you are on windows, such that you don't have to remember both the Linux and the Windows command for listing directories.
回答2:
The command you are looking for is called ls
(for list). Run it as
ls -als
to see all files and directories in the current directory.
Take a look at the Bash tutorial here, which will give you an overview of the most commonly used commands.
http://www.cs.uwp.edu/staff/knautz/BashTutorial-1.0.0/bt.php?p=tutorial01
回答3:
Git bash runs bash, so you can use bash commands, i.e:
ls -la
You can have a look at basic bash commands, to list files, delete, show content, etc, here: http://tldp.org/LDP/abs/html/basic.html
回答4:
A simple ls should be enough.
since git bash is a regular unix bash, regular unix commands do work.
That being said, I prefer using a regular cmd session, using the git-cmd.bat script provided with msysgit.
That way, all git commands are available while the regular DOS commands do work.
来源:https://stackoverflow.com/questions/28738331/show-files-in-current-directory-using-git-bash