liwya 发表于 2018-1-14 21:20:53

Git集成到Visual Studio 2012

概述
  本方案是采用gitextensions+git source control provider+visual studio 2012

安装环境

下载gitextensions
  https://code.google.com/p/gitextensions/downloads/list
  安装的时候勾选msysGit和 KDiff3,其他全部使用默认配置即可
  安装成功后,可以看到桌面上新增如下两个图标
https://images0.cnblogs.com/blog/384558/201304/22003338-82d069dafcf040369e0260e5df25d2e0.png

安装Git Source Control Provider
  在VS的"工具"--"扩展和更新"中搜索,并下载
  Git Source Control Provider
  下载完成后,安装,重启VS,在菜单中可以看到"Git"菜单项
https://images0.cnblogs.com/blog/384558/201304/22003339-330d5bc60e0c44c59a42b8097aad0598.png
  在"工具"—"选项"中修改源代码管理插件为Git Source Control Provider
https://images0.cnblogs.com/blog/384558/201304/22003340-317129a444fe4342ba42f01a7330504c.png

注册GITHUB帐号并创建库
  访问 https://github.com/,并注册帐号,登录
https://images0.cnblogs.com/blog/384558/201304/22003342-6258cc78b3da44c2b7b3fa99c4e15789.png
  点击右上角的"Account Settings"
https://images0.cnblogs.com/blog/384558/201304/22003345-86fc7a467a7a474598edde383fb90101.png
  选择"SSH Keys",根据如下指南新建SSH KEY
  https://help.github.com/articles/generating-ssh-keys
https://images0.cnblogs.com/blog/384558/201304/22003347-5beb5c5c64354006b880a7e44a827d92.png
  文本如下
  

Welcome to Git (version 1.8.1.2-preview20130201)  

  
Run 'git help git' to display the help index.
  

  
Run 'git help <command>' to display help for specific commands.
  

  
Administrator@WS-WWANG-13 ~
  

  
$ get help git
  

  
sh.exe": get: command not found
  

  
Administrator@WS-WWANG-13 ~
  

  
$ git help git
  

  
Launching default browser to display HTML ...
  

  
Administrator@WS-WWANG-13 ~
  

  
$ cd ~/.ssh
  

  
sh.exe": cd: /c/Users/Administrator/.ssh: No such file or directory
  

  
Administrator@WS-WWANG-13 ~
  

  
$ ssh-keygen -t rsa -C "davidww11"
  

  
Generating public/private rsa key pair.
  

  
Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa):
  

  
Created directory '/c/Users/Administrator/.ssh'.
  

  
Enter passphrase (empty for no passphrase):
  

  
Enter same passphrase again:
  


  
Your>  

  
Your public key has been saved in /c/Users/Administrator/.ssh/id_rsa.pub.
  

  
The key fingerprint is:
  

  
65:5f:b6:1e:92:61:53:b2:4c:34:11:fa:95:db:60:2e davidww11
  

  
Administrator@WS-WWANG-13 ~
  

  
$ clip < ~/.ssh/id_rsa.pub
  

  
Administrator@WS-WWANG-13 ~
  

  
$ ssh -T git@github.com
  

  
The authenticity of host 'github.com (204.232.175.90)' can't be established.
  

  
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
  

  
Are you sure you want to continue connecting (yes/no)? yes
  

  
Warning: Permanently added 'github.com,204.232.175.90' (RSA) to the list of know
  

  
n hosts.
  

  
Enter passphrase for key '/c/Users/Administrator/.ssh/id_rsa':
  

  
Hi davidww11! You've successfully authenticated, but GitHub does not provide she
  

  
ll access.
  

  
Administrator@WS-WWANG-13 ~
  

  
$
  

  

https://images0.cnblogs.com/blog/384558/201304/22003348-63d34de39a51493a8e39f2d7c08e6305.png
  如上,生成KEY以后,生成PuTTY Key
  打开Git Extensions
https://images0.cnblogs.com/blog/384558/201304/22003348-58a86509f9dc42cfb7a8200fd7c1ee1c.png
  选择菜单项"远程"—"PuTTY"—"生成或者导入key"
https://images0.cnblogs.com/blog/384558/201304/22003349-1dd9b32b23e7402bae3ec423135e427a.png
  打开菜单项"Conversions"—"Import key"
https://images0.cnblogs.com/blog/384558/201304/22003349-1908001041554cad82376434084f3685.png
  选择刚刚生成的SSH Key
https://images0.cnblogs.com/blog/384558/201304/22003350-5d90df10ebc646369e7c03b192c45acc.png
  选择"Save Private Key",生成PuTTY Key
https://images0.cnblogs.com/blog/384558/201304/22003350-4905c10d63ed4ccfbcd9dcdfb357a337.png
  新建库
  在右上角,点击自己的用户名,打开自己的GIT页面,点击"Repositories",点击"New",创建一个新库"TestGit01"
https://images0.cnblogs.com/blog/384558/201304/22003351-a86675aa394c44b9a15e69817bfecd04.png

连接并上传
  用VS在本地打开或新建一个项目,在解决方案上右键,选择"Create Git Repository"
  在解决方案上点击右键 ,选择"Git"—"Push"
https://images0.cnblogs.com/blog/384558/201304/22003352-d7f4915372f443769a6df059db504083.png
  选择管理远程
https://images0.cnblogs.com/blog/384558/201304/22003352-fdda2bb7709f45928f3561429be0862b.png
  填写刚刚新建的库的地址
https://images0.cnblogs.com/blog/384558/201304/22003352-bec0aa0d23e44a5897d649a960f3dc68.png
  git@github.com:davidww11/TestGit01.git
  加载刚刚新建的PuTTY Key文件,并点击"加载SSH密钥",测试连接,通过后,点击保存
https://images0.cnblogs.com/blog/384558/201304/22003353-6734cb490b8043c6983e3128cca04155.png
https://images0.cnblogs.com/blog/384558/201304/22003353-7e99731d1d7843eb8bffd3b98e1b31f0.png
  点击"拉取"—"解决冲突",确定后,再返回,点击"推送",完成代码的签入
https://images0.cnblogs.com/blog/384558/201304/22003354-ddd94fefaf9940398a55e8454fc44872.png
页: [1]
查看完整版本: Git集成到Visual Studio 2012