Visual Studio Code:.git 文件夹/文件隐藏

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

Visual Studio Code: .git folder/file hidden

gitvisual-studio-code

提问by Bumsik Kim

I am trying Visual Studio Code at this moment. Everything about Visual Studio Code look really cool to me except one thing: .git folder/file is hidden in Visual Studio Code.

我现在正在尝试 Visual Studio Code。关于 Visual Studio Code 的一切对我来说都非常酷,除了一件事:.git 文件夹/文件隐藏在 Visual Studio Code 中。

I often change Git setting by modifying the .git configuration file. It is really annoying for me not able to see .git files.

我经常通过修改 .git 配置文件来更改 Git 设置。无法看到 .git 文件对我来说真的很烦人。

Is there a way to reveal .git files in Visual Studio Code?

有没有办法在 Visual Studio Code 中显示 .git 文件?

回答by Nishant Singh

By default Visual Studio Code excludes files in a folder using the following settings:

默认情况下,Visual Studio Code 使用以下设置排除文件夹中的文件:

"files.exclude": {
    "**/.git": true,
    "**/.svn": true,
    "**/.hg": true,
    "**/.DS_Store": true
}

You can change your user settings or workspace settings to show the .git folder by adding these lines:

您可以通过添加以下行来更改用户设置或工作区设置以显示 .git 文件夹:

"files.exclude": {
     "**/.git": false
}

回答by Vikash Kumar Choudhary

The below steps can be followed to override the existing user setting:

可以按照以下步骤覆盖现有用户设置:

  1. Menu CodePreferenceSetting
  2. Search for files.exclude
  3. Mouse over files.excludeproperty, click on the edit icon and then opt for the copy to settings.
  4. The above steps will add all the properties, but keep only those which need to be overridden. For this case: it should be, "files.exclude": { "**/.git": false }
  5. Close the user setting. the .gitfolder will automatically appear in the respective repository.
  1. 菜单代码首选项设置
  2. 搜索 files.exclude
  3. 将鼠标悬停在files.exclude属性上,单击编辑图标,然后选择复制到设置。
  4. 上述步骤将添加所有属性,但仅保留需要覆盖的属性。对于这种情况:应该是, "files.exclude": { "**/.git": false }
  5. 关闭用户设置。该.git文件夹将自动出现在相应的存储库中。

回答by someone_alive

The settings for Visual Studio Code can be found:

可以找到 Visual Studio Code 的设置:

  • On a Windows or Linux computer, click menu FilePreferencesSettings
  • On a Mac, click menu CodePreferencesSettings
  • 在 Windows 或 Linux 计算机上,单击菜单文件首选项设置
  • 在 Mac 上,单击菜单代码首选项设置

There are both users settings (for everyone) and workspace settings for individual projects.

个人项目既有用户设置(适用于所有人),也有工作区设置。

More instructions can be found at: User and Workspace Settings

可以在以下位置找到更多说明: 用户和工作区设置

回答by Ishan Patel

You can access this setting in the settings option.

您可以在设置选项中访问此设置。

Then we need to copy this particular settings section to the right side and make the changes.

然后我们需要将此特定设置部分复制到右侧并进行更改。

回答by Arik

You should also be aware of the search.useIgnoreFilessetting, which will ignore files and folders that are ignored using .gitignoreand .ignorefiles.

您还应该注意该search.useIgnoreFiles设置,该设置将忽略使用.gitignore.ignorefiles忽略的文件和文件夹。

回答by Isaac Pak

It's probably best to leave this hidden

最好把这个隐藏起来

If you are using the sidebar to navigate and edit files, it would leave an opportunity to accidentally drop a file or folder in it, or accidentally move it to a different location. A better solution would be to open a terminal session in Visual Studio Code and then do code .git. That will open the folder in another Visual Studio Code instance and from there you can edit it.

如果您使用侧边栏来导航和编辑文件,则可能会意外地将文件或文件夹放入其中,或者意外地将其移动到其他位置。更好的解决方案是在 Visual Studio Code 中打开一个终端会话,然后执行code .git. 这将在另一个 Visual Studio Code 实例中打开该文件夹,您可以从那里对其进行编辑。