Windows 中 git 隐藏文件夹的命令

发布于 2025-01-10 05:37:57 字数 120 浏览 0 评论 0原文

在Windows中显示Git存储库中的隐藏文件夹的命令是什么?

例如 - Mac 中的命令是 ls -lals -a

我是 git 新手。

What are the commands for showing the hidden folders in Git repository in windows?

For example - command in mac is ls -la or ls -a.

I am new to git.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

决绝 2025-01-17 05:37:57

最简单的方法:使用 git-bash 或从 WSL(适用于 Linux 的 Windows 子系统)启动终端。

您将拥有一个可以访问标准 Linux 实用程序的 bash shell,并且 ls -la 应该可以在此类终端上工作。


如果您启动了 Powershell 终端,请尝试 ls -Hidden

ls 实际上是 powershell 命令的别名Get-ChildItem

Powershell 团队将许多常用的 Linux 命令名称映射到 Powershell 内置命令(例如:cd -> Set-Locationuniq - > Get-Unique, pushd -> Push-Location, ... ),但没有映射选项,所以ls 期望的选项在 Powershell 终端中,不是 -a ...而是 Get-ChildItem 的选项。

弄清楚您所知道的“linux”命令名称的预期内容的一种方法是输入: get-help 您将看到实际的 powershell 命令名称及其所需的选项,例如 :

$ get-help ls

NAME
    Get-ChildItem

SUMMARY
    Gets the items and child items in one or more specified locations.


SYNTAX
    Get-ChildItem [[-Filter] <System.String>] [-Attributes {Archive | Compressed | Device | Directory | Encrypted |
    Hidden | IntegrityStream | Normal | NoScrubData | NotContentIndexed | Offline | ReadOnly | ReparsePoint |
    SparseFile | System | Temporary}] [-Depth <System.UInt32>] [-Directory] [-Exclude <System.String[]>] [-File]
    [-Force] [-Hidden] [-Include <System.String[]>] -LiteralPath <System.String[]> [-Name] [-ReadOnly] [-Recurse]
    [-System] [-UseTransaction] [<CommonParameters>]

    Get-ChildItem [[-Path] <System.String[]>] [[-Filter] <System.String>] [-Attributes {Archive | Compressed | Device
    | Directory | Encrypted | Hidden | IntegrityStream | Normal | NoScrubData | NotContentIndexed | Offline | ReadOnly
    | ReparsePoint | SparseFile | System | Temporary}] [-Depth <System.UInt32>] [-Directory] [-Exclude
    <System.String[]>] [-File] [-Force] [-Hidden] [-Include <System.String[]>] [-Name] [-ReadOnly] [-Recurse]
    [-System] [-UseTransaction] [<CommonParameters>]


DESCRIPTION
    The `Get-ChildItem` cmdlet gets the items in one or more specified locations. [...]

The simplest way : start a terminal using git-bash, or from WSL (Windows Subsystem for Linux).

You will have a bash shell with access to the standard linux utilies, and ls -la should work from such terminals.


If you started a Powershell terminal, try ls -Hidden.

ls is actually an alias to the powershell command : Get-ChildItem.

The Powershell team mapped a number of usual linux command names to Powershell built-ins (e.g : cd -> Set-Location, uniq -> Get-Unique, pushd -> Push-Location, ... ), but didn't map the options, so the options expected by ls in a Powershell terminal aren't -a ... but rather the options to Get-ChildItem.

One way to figure out what's expected from a "linux" command name you know is to type : get-help <command name> you will see the actual powershell command name, and the options it expects, for example :

$ get-help ls

NAME
    Get-ChildItem

SUMMARY
    Gets the items and child items in one or more specified locations.


SYNTAX
    Get-ChildItem [[-Filter] <System.String>] [-Attributes {Archive | Compressed | Device | Directory | Encrypted |
    Hidden | IntegrityStream | Normal | NoScrubData | NotContentIndexed | Offline | ReadOnly | ReparsePoint |
    SparseFile | System | Temporary}] [-Depth <System.UInt32>] [-Directory] [-Exclude <System.String[]>] [-File]
    [-Force] [-Hidden] [-Include <System.String[]>] -LiteralPath <System.String[]> [-Name] [-ReadOnly] [-Recurse]
    [-System] [-UseTransaction] [<CommonParameters>]

    Get-ChildItem [[-Path] <System.String[]>] [[-Filter] <System.String>] [-Attributes {Archive | Compressed | Device
    | Directory | Encrypted | Hidden | IntegrityStream | Normal | NoScrubData | NotContentIndexed | Offline | ReadOnly
    | ReparsePoint | SparseFile | System | Temporary}] [-Depth <System.UInt32>] [-Directory] [-Exclude
    <System.String[]>] [-File] [-Force] [-Hidden] [-Include <System.String[]>] [-Name] [-ReadOnly] [-Recurse]
    [-System] [-UseTransaction] [<CommonParameters>]


DESCRIPTION
    The `Get-ChildItem` cmdlet gets the items in one or more specified locations. [...]
暗藏城府 2025-01-17 05:37:57

如果OP只是要求在常规Windows命令终端(cmd.exe)中查看隐藏的.git文件夹,那么最简单的方法是使用dir命令和/a 属性。这是与 ls -a 最简单的本机等效项。

C:\Users\--redacted-->dir /a
 Volume in drive C has no label.
 Volume Serial Number is --redacted--

 Directory of C:\Users\--redacted--

2022-10-29  10:31 PM    <DIR>          .
2022-10-29  10:31 PM    <DIR>          ..
2022-10-29  10:31 PM    <DIR>          .git
2022-10-29  10:31 PM               489 .gitignore
...

如果不使用 /a,则看不到 .git 文件夹:

C:\Users\--redacted-->dir
 Volume in drive C has no label.
 Volume Serial Number is --redacted--

 Directory of C:\Users\--redacted--

2022-10-29  10:31 PM    <DIR>          .
2022-10-29  10:31 PM    <DIR>          ..
2022-10-29  10:31 PM               489 .gitignore
...

这是因为 .git 文件夹设置了隐藏 Windows 文件属性,如下所示:使用 attrib 命令查看:

C:\Users\--redacted-->attrib .git
    H                C:\Users\--redacted--\.git

输入 dir /? 以获取可与 dir 一起使用的所有标志。

If the OP is asking to simply see the hidden .git folder in a regular Windows Command terminal (cmd.exe), then the easiest is to use the dir command with the /a attribute. This is the simplest native equivalent to ls -a.

C:\Users\--redacted-->dir /a
 Volume in drive C has no label.
 Volume Serial Number is --redacted--

 Directory of C:\Users\--redacted--

2022-10-29  10:31 PM    <DIR>          .
2022-10-29  10:31 PM    <DIR>          ..
2022-10-29  10:31 PM    <DIR>          .git
2022-10-29  10:31 PM               489 .gitignore
...

If you do not use the /a, you don't see the .git folder:

C:\Users\--redacted-->dir
 Volume in drive C has no label.
 Volume Serial Number is --redacted--

 Directory of C:\Users\--redacted--

2022-10-29  10:31 PM    <DIR>          .
2022-10-29  10:31 PM    <DIR>          ..
2022-10-29  10:31 PM               489 .gitignore
...

This is because the .git folder has the Hidden Windows file attribute set, as can be seen with the attrib command:

C:\Users\--redacted-->attrib .git
    H                C:\Users\--redacted--\.git

Enter dir /? for all the flags that can be used with dir.

不离久伴 2025-01-17 05:37:57

首先你必须找到路径,主要是在桌面上
C:\Users\我的电脑\桌面\ .git
如果你找到该文件夹
只需在文件资源管理器中输入路径,然后按 Enter 键即可
然后文件就在该文件夹中,只需将其复制并粘贴到您想要的任何位置

First u have to find the path mostly it is in desktop
C:\Users\my pc\Desktop\ .git
if you find the folder
simply enter the path into the File explorer then hit enter
then the files is in that folder only simply copy and paste it wherever you want

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文