简体   繁体   English

VSCode Git命令并跟踪更改

[英]VSCode Git commands and tracking changes

I'm using Visual Studio Code in Windows 10 and also have Git installed. 我在Windows 10中使用Visual Studio Code,并且还安装了Git。

I have encountered two issues: 我遇到了两个问题:

  1. I have tried to perform Git commands on the "command palette" (as shown on many VSCode tutorials) but VSCode is not recognizing any commands. 我试图在“命令面板”上执行Git命令(如许多VSCode教程中所示),但是VSCode无法识别任何命令。 I ended using the "integrated terminal" using bash.exe to clone my repository and checkout master . 我结束了使用bash.exe的“集成终端”来克隆我的存储库和checkout master That did the trick and now I can see my project under the Explorer icon. 做到了这一点,现在我可以在“资源管理器”图标下看到我的项目。

    Now that I have files and VSCode sees them if i try to use again the "command palette" to checkout or pull or commit it is not seeing my repository or branches or master. 现在,我已经有了文件,并且如果我再次尝试使用“命令面板”进行检出,拉出或提交操作,VSCode将看到它们,这是没有看到我的存储库,分支或主服务器的。 I have to go back and use the "integrated terminal". 我必须返回并使用“集成终端”。

    Why is the "command palette" not working? 为什么“命令面板”不起作用?

  2. If I edit any of my files under the Explorer icon that I previously cloned and checkout the changes are not shown under the Git icon. 如果我在以前克隆的资源管理器图标下编辑任何文件并检出,则更改不会显示在Git图标下。

    But I've noticed that if I make changes to the settings.json (VSCode preference file) it shows under the Git icon that changes have been made and it asks me if I want to commit the changes. 但是我注意到,如果我对settings.json(VSCode首选项文件)进行了更改,它会在Git图标下显示已进行更改,并且询问我是否要提交更改。

    Why is it that VSCode is not tracking or showing the changes I've made on my own files and only track the changes on its own files? 为什么VSCode不跟踪或显示我对自己文件所做的更改,而仅跟踪其自身文件上的更改?

Visual Studio Code "Version Control" page mentions: Visual Studio代码“版本控制”页面提到:

Visual Studio Code has integrated Git support for the most common commands. Visual Studio Code为最常见的命令集成了Git支持。

Note: VS Code will leverage your machine's Git installation, so you need to install Git first before you get these features. 注意:VS Code将利用计算机的Git安装,因此在获得这些功能之前,需要首先安装Git。 Make sure you install at least version 2.0.0 确保至少安装了2.0.0版

So make sure first Git for Windows is installed and in your %PATH% before launching Visual Studio Code. 因此,在启动Visual Studio Code 之前 ,请确保首先在Windows的Git中安装了Git,并且在您的%PATH%

Open VS in the root folder of your Git repo. 在您的Git存储库的根文件夹中打开VS。 As mentioned: 如上所述:

You can open VS Code in a sub-directory of a Git repository. 您可以在Git存储库的子目录中打开VS Code。 VS Code's Git services will still work as usual, showing all changes within the repository, but file changes outside of the scoped directory are shaded with a tool tip indicating they are located outside the current workspace. VS Code的Git服务仍将照常运行,显示存储库中的所有更改,但是作用域目录之外的文件更改将用工具提示阴影化,以指示它们位于当前工作空间之外。

The OP fmora adds in the comments : OP fmora 在评论中添加:

I need to open the folder via VSCode in the File menu and it works 我需要通过“文件”菜单中的VSCode打开文件夹,并且它可以工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM