如何使用 windows powershell 显示隐藏文件(dotfiles)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/50817139/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 20:04:19  来源:igfitidea点击:

How to show hidden files (dotfiles) with windows powershell

windowspowershelldotfiles

提问by fuma

When I have hidden files, like dotfilesor a .gitdirectory: How can I list those files and directories in Powershell?

当我有隐藏文件(如dotfiles.git目录)时:如何在 Powershell 中列出这些文件和目录?

Neither Get-ChildItem, dirnor lsseem to show them.

既不Get-ChildItemdir也不ls似乎显示它们。

回答by fuma

In order to show such hidden files, use the -Forceparameter for the Get-Childitemcommand.

为了显示此类隐藏文件,请使用命令的-Force参数Get-Childitem

Get-ChildItem . -Force

You also can use its aliases, with -Force

你也可以使用它的别名, -Force

dir -Force
ls -Force
gci -Force

Also: if you want to delete fully delete e.g. the .git Directory, you may use Delete-Item .\.git -Force

另外:如果你想完全删除例如.git Directory,你可以使用Delete-Item .\.git -Force

EDIT

编辑

According to Get-Help Get-ChildItem -Examples"Example 3" this also works: dir -att h, !h

根据Get-Help Get-ChildItem -Examples“示例 3”,这也有效: dir -att h, !h