为什么 Visual Studio 代码强制我使用远程 GitHub 存储库?

Why does Visual Studio Code force me to use a remote GitHub repository?

初始化本地存储库并进行初始提交后,VS 代码提示我 'Publish Branch' on GitHub。

我不想使用 GitHub,因为在这种情况下我很乐意使用本地存储库。这可能吗?我找不到忽略 'Publish Branch' 提示的选项。

在初始化存储库之前:

初始化存储库后:

提交后:

它并不是真的强迫你或提示你将你的 repo 发布到 Github。

它更多的是一种选择、提示或建议,因为当有人使用 Git 时,他们通常会希望 push/publish 将他们的回购协议的本地副本 push/publish 到相同的回购协议(例如与您团队的其他成员共享等)。但是如果你想要的只是在本地维护它,那么使用 Git 以及 Visual Studio 代码的源代码控制功能是完全没问题的。它不应该阻止您进行进一步的本地提交。

所以

I don't want use GitHub do as I am happy using a local repo in this case - is this possible?

是。

I can't find an option to ignore the 'Publish Branch' prompt.

如果您不想看到该按钮,可以使用 Git 中的设置隐藏它:显示未发布的提交 VS Code 1.61 September 2021

By default, the Git extension will add a Sync Changes button as shown above, if there are unpushed commits, or a Publish Changes button if the branch hasn't yet been published. Additionally, users can customize this behavior by configuring the git.showUnpublishedCommitsButton setting, which defaults to whenEmpty so that the button will only be shown if there are unpushed commits and there are no other changes in the view.

"git.showUnpublishedCommitsButton": "never"

Just thought it looked a little odd as it differed from (albeit old) docs showing nothing, seemed intrusive, and was different to what I'm used to.

这可能是持续更新的一部分,进一步将 Github 与 VS Code 的 UI 集成(since both are now owned by Microsoft). The section on Initializing a Repository 没有提到它需要发布到 Git集线器或任何其他提供商。

需要说明的是,您几乎可以使用任何远程存储库 server/provider。它不一定是 Github。 (虽然内置 UI 是专门为使用 Git 集线器而设计的。)