如何从VS Code中删除或修改存储库

huangapple go评论98阅读模式
英文:

How to remove or modify a repository from vscode

问题

我刚刚将我的存储库添加到 vscode 源代码控制中(使用“初始化存储库”按钮),现在它显示我有 1800 个更改。在 Github Desktop 中,它正确显示了两个已更改的文件。我该怎么办?

我应该从 vscode 中删除存储库,然后重新添加它吗?有没有办法检查 vscode 正在从哪里获取存储库?也许它正在检查错误的目录?或者可能它是正确的,而 Github Desktop 是错误的?

vscode:
如何从VS Code中删除或修改存储库

Github Desktop:
如何从VS Code中删除或修改存储库

注:
我在 vscode 中打开的文件夹是主存储库的子文件夹。

示例:
/mygitproject
/mygitproject/workingfolderinvscode

之前:
如何从VS Code中删除或修改存储库

更新:
重新启动 vscode 弹出了此消息:
如何从VS Code中删除或修改存储库

关闭项目,然后打开父文件夹,得到了上面提到的相同消息。这一次,一些文件和文件夹没有更改,而其他文件和文件夹未被跟踪。在文件资源管理器的右侧添加(下面的屏幕截图)。实际上,打开文件夹时,我看到所有文件都没有被跟踪,现在文件夹显示为未被跟踪。
如何从VS Code中删除或修改存储库

更新:
我现在已打开源代码控制视图,在打开父分支后,我看到列出了两个存储库。顶部的显示了正确的更改数目,底部的显示了不正确的。
如何从VS Code中删除或修改存储库

更新:
看起来,如果我右键单击存储库的名称,我会得到一些选项,包括“关闭存储库”。
如何从VS Code中删除或修改存储库

我将关闭显示为子目录的存储库,保留包含项目的根目录的存储库。
成功!
它显示正确。
如何从VS Code中删除或修改存储库

英文:

I just added my repository to vscode source control (using the Initialize repository button) and it now says I have 1800 changes. In Github Desktop it correctly shows two changed files. What should I do?

Should I remove the repository from vscode and how and then readd it back in? Is there a way to check where vscode is getting the repository? Maybe it is checking the wrong directory? Or maybe it is correct and github Desktop is incorrect?

vscode:
如何从VS Code中删除或修改存储库

github desktop:

如何从VS Code中删除或修改存储库

Note:
My folder that is open in vscode is a subfolder of the main repository.

Example:

/mygitproject
/mygitproject/workingfolderinvscode

Before:

如何从VS Code中删除或修改存储库

Update:
Restarting vscode popped up this message:

如何从VS Code中删除或修改存储库

Closed the project and opened the parent folder and got the same message mentioned above. This time some folders and files are unchanged and others are untracked. Adding right side of file explorer (screenshot below). Actually, on opening the folders I see that all the files all untracked and now the folders show untracked.

如何从VS Code中删除或修改存储库

Update:
I've opened the source control view now, after opening up the parent branch and I see two repositories listed. The top one shows the correct number of changes and the bottom one the incorrect.

如何从VS Code中删除或修改存储库

UPDATE:
It looks like if I right click on the name of the repository I get a few options including, "Close Repository".

如何从VS Code中删除或修改存储库

I'm going to close the repository that shows as the subdirectory and keep the repository that includes the projectd from it's root directory.

Great success!

It is showing up correctly.

如何从VS Code中删除或修改存储库

答案1

得分: 1

我猜测你的VSCode显示了主目录中所有已更改的文件,而不仅仅是子目录中的文件。 Git status 可以提供更多细节。

但在VSCode的源代码控制选项卡中,你可以选择要提交和推送的文件,如果需要的话。

英文:

My guess is, your VSCODE is showing all the files in the main directory that has changed. Not only the ones in your subdirectory. Gis status can give more details about.

But in the source control tab of VSCode you can select the files you want to commit and push if necessary.

答案2

得分: 0

显然,vscode不喜欢我打开了一个子文件夹,而不是根文件夹(带有git文件夹的那个)。

然后我打开了包含git文件夹的文件夹。

然后显示了两个存储库。

要关闭第一个存储库,我右键单击源代码控制面板中的存储库名称,然后选择“关闭存储库”。

现在显示了正确的信息。

但还不止于此。当我重新打开项目时,第一个存储库再次打开,导致与之前相同的问题。我在子目录中找到了一个.git文件夹并已删除它。

英文:

Apparently, vscode did not like that I had a sub folder open instead of the root folder (the one with git folder).

I then opened the folder that had the git folder in it.

It then showed two repositories.

如何从VS Code中删除或修改存储库

To close the first repository, I right clicked on the repository name in the source control panel and chose, "Close repository".

如何从VS Code中删除或修改存储库

It now shows the correct information.

But that is not all. When I reopened the project the first repository opened again causing the same issue as before. I found a .git folder in the subdirectory and have deleted it.

huangapple
  • 本文由 发表于 2023年2月19日 01:46:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/75495232.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定