使用 Git Bash 显示当前目录中的文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28738331/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Show files in current directory using Git Bash?
提问by kxc
How can I check files in current directory, from git bash?
Like command dir
, in Windows cmd
?
如何从 git bash 检查当前目录中的文件?像命令一样dir
,在 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?
我找到了一个命令git ls-files
,但它仅适用于 git 存储库文件。但是如果我通过驱动器 C:\ 导航,并想查看当前目录中的文件,我该如何在 git bash 中做到这一点?
回答by ArchiFloyd
The git bash is basically a Unix shell, therefore you can list current files and directories with the ls
command
git bash 基本上是一个 Unix shell,因此您可以使用以下ls
命令列出当前文件和目录
You can also use ls -a
to show hidden files and folders.
您还可以使用ls -a
来显示隐藏的文件和文件夹。
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.
由于它是一个 Unix shell,您可以dir
在 .bashrc 文件中创建一个别名。当您在 Windows 上时,它很方便,这样您就不必同时记住 Linux 和 Windows 命令来列出目录。
回答by nwinkler
The command you are looking for is called ls
(for list). Run it as
您正在寻找的命令被称为ls
(列表)。运行它
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.
看看这里的 Bash 教程,它会给你一个最常用命令的概述。
http://www.cs.uwp.edu/staff/knautz/BashTutorial-1.0.0/bt.php?p=tutorial01
http://www.cs.uwp.edu/staff/knautz/BashTutorial-1.0.0/bt.php?p=tutorial01
回答by VonC
A simple ls
should be enough.
一个简单的ls
应该足够了。
since git bash is a regular unix bash, regular unix commands do work.
由于 git bash 是常规的unix bash,因此常规的 unix 命令确实有效。
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.
话虽如此,我更喜欢使用常规的 cmd 会话,使用git-cmd.bat
msysgit 提供的脚本。
这样,所有 git 命令都可用,而常规 DOS 命令可以工作。
回答by danielfranca
Git bash runs bash, so you can use bash commands, i.e:
Git bash 运行 bash,所以你可以使用 bash 命令,即:
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
您可以在此处查看基本的 bash 命令,以列出文件、删除、显示内容等:http: //tldp.org/LDP/abs/html/basic.html