如何将 Visual Studio 2012 与 git (github) 连接?

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

How to Connect Visual Studio 2012 with git (github)?

gitvisual-studiovisual-studio-2012github

提问by Sumit Chourasia

Microsoft launched Visual studio 2012 which can be integrated with Git (and github), I'm using the following reference linking visual studio 2012 with git, but i'm not getting any option to commit my code. Do i need to install/use Github for windows? Or is it possible to integrate with github directly from visual studio?

Microsoft 推出了可以与 Git(和 github)集成的 Visual Studio 2012,我使用以下参考链接 Visual Studio 2012 与 git,但我没有任何选项来提交我的代码。我需要为 Windows 安装/使用 Github 吗?或者是否可以直接从 Visual Studio 与 github 集成?

This is the solution explorer not showing the Git context menu items.

This is the solution explorer not showing the Git context menu items.

回答by jessehouwing

First of all, install Visual Studio 2012 Update 3and the Visual Studio Tools for Gitto enable Git support in 2012. And you must ensure that Git for Windows is installed(Visual Studio will prompt you to install it if you haven't done so).

首先,安装Visual Studio 2012 Update 3Visual Studio Tools for Git以在 2012 年启用 Git 支持。并且你必须确保安装Git for Windows(如果你没有安装,Visual Studio 会提示你安装它) )。

If you're using Visual Studio 2013 or later, Git support is built in and doesn't require any plugin installation.

如果您使用的是Visual Studio 2013 或更高版本,则内置了 Git 支持,不需要安装任何插件。

Then, under Source Control, ensure that you have the "Microsoft Git Provider" enabled: Select Source Control provider

然后,在源代码管理下,确保您启用了“Microsoft Git Provider”: Select Source Control provider

Open the Team Explorer tab. When you click the connectbutton in the toolbar (looks like a power plug), make sure your repository is listed under Local Git Repositories, or use the cloneoption to clone a repository to your system.

打开团队资源管理器选项卡。当您单击connect工具栏中的按钮(看起来像电源插头)时,请确保您的存储库列在本地 Git 存储库下,或使用该clone选项将存储库克隆到您的系统。

enter image description here

enter image description here

When you click clone you can enter an existing GitHub repository location, use the "HTTPS" location of your repository. Visual Studio doesn't support SSH. You can use the location picker on your GtiHub repository page to get the right clone url.

单击克隆时,您可以输入现有的 GitHub 存储库位置,使用存储库的“HTTPS”位置。Visual Studio 不支持 SSH。您可以使用 GtiHub 存储库页面上的位置选择器来获取正确的克隆 URL。

enter image description here

enter image description here

Select Existing GitHub

Select Existing GitHub

Then finally, on the Unsynced Commitstab you can click Sync to synchronize your local repository with the remote, this will ask for your GitHub credentials.

最后,在Unsynced Commits选项卡上,您可以单击同步以将本地存储库与远程存储库同步,这将要求您提供 GitHub 凭据。

Sync

Sync

If you want to create a new repository from scratch, I have not the slightest idea of how to do that from the UI, but after creating an empty repository on GitHub, you should be able to add a new remote from the commandline. Visual Studio will then pick up that remote and allow you to push into it.

如果您想从头开始创建一个新存储库,我对如何从 UI 执行此操作一无所知,但是在 GitHub 上创建一个空存储库后,您应该能够从命令行添加一个新的远程存储库。Visual Studio 然后将拿起那个遥控器并允许你推入它。

See the following steps on github to initialize an empty repositoryand setup the link between your local repository and github. Once you've done that, the repository should show up in Visual Studio as well (if it doesn't, add it using the addoption on the connect page of Team Explorer).

请参阅github 上以下步骤以初始化一个空存储库并设置本地存储库和 github 之间的链接。完成此操作后,存储库也应显示在 Visual Studio 中(如果没有,请使用addTeam Explorer 的连接页面上的选项添加它)。

enter image description here

enter image description here