With TorToiseGit to manage the project on github

Reprinted from: Click on the link to open

Personal added: I use this link , there is the final push if unsuccessful, to pull down and then push. Other operations follow.


Recently feel the code on the computer too messy, East 1, West ...... I decided to use a formal source code management software to manage their own code later wrote. Used to do small projects, when used TortoiseSVN, feeling good, but a bit slow on the speed and decided to try something new --Git. Git by Network Discovery is the fire, look at the following text Git you will know how the fire.

        Git is a distributed version control system, originally written by Linus Torvalds, Linux kernel code used for the management. After the launch, Git in other projects also achieved great success, especially in the Ruby community. At present, including Rubinius and Merb, including many well-known projects using Git. Git can also be used as such Capistrano and Vlad the Deployer deployment tools.

        At present, most require a version control server, submitted to the server when the commit. While git is a distributed management tool, but it can also use centralized management. For example, billy create a new project, tom feel that this project is more interesting, he wanted to play with, he can put the entire repo (reoisitories) to clone both locally and down in his clone projects that they have a repo. tom free to make various modifications to the submission of this repo, until he was satisfied. Then you can tell billy tom, he changed some what, if billy feel good, you can fetch from tom side and merge locally.

        As described above, as a distributed version control system, there is not only a main library in Git, each copy of the library can be used independently, any inconsistencies between the two libraries may be merger. Because of this, it has Github this site, github is based on a blend of ruby ​​and development of languages, the above ruby ​​project is also very active. In github, each person can have multiple repo, the repo is tied to the user together. User can clone repo between each other, the same fork repo, watch repo or follow other user, just like plurk twitter or other social networking sites.

        However, if you use the free github repo should all be public and limited capacity of 300M. If there is a private hope repo, you need to talk to a fee. Another github clipboard features, which can be attached to the code and the development of various free branch.

        GitHub hosts git repository, and provides a web interface, but other services like SourceForge or Google Code different, GitHub's unique selling point is the easy branching from another project. For a project to contribute code is very simple: First, click on the project site of the "fork" button, and then modify the code detected and added to your forked codebase, ultimately responsible to the project through the built-in "pull request" mechanism people proposing a merge. GitHub has already been referred to the Code of players Facebook.

        Read the introduction above, I feel pretty good. Then we begin to act now.

1 Download and install the software

        Here the main software involved include msysgit and TortoiseGit.

Download msysgit of: http://msysgit.googlecode.com/files/Git-1.7.4-preview20110204.exe

Download TortoiseGit of: http://code.google.com/p/tortoisegit/downloads/list (select the version to download your favorite)

        Before installing TortoiseGit, msysgit must be installed on your Windows PC. Because this program provides core Git. And the installation sequence is: install msysgit, and then install TortoiseGit . If you backwards, it does not matter, you can enter TortoiseGit settings interface (TortoiseGit on the right-click menu -> Settings -> General -> MSysGit -> Path), manually specify the location Git core document (for example, c: \ Program Files \ git \ bin). Noticed, when you enter the settings interface has been configured, the software had to say now doing really good.

2 to establish their own accounts on github.com

        Earlier he said, github is the programmer's facebook, so we should have our own account. Two types of accounts, free accounts and paid accounts. Free use of github, all repo should be public and limited capacity of 300M; if want to have a private repo, you need to pay before. In the free exchange of attitude, or apply for a free account now. This process is very easy, I will not say more.

        After registering, github provides several tutorials for everyone, to help you quickly learn to master the use github. At the following address:

Set Up Git Tutorial: http://help.github.com/win-set-up-git/

Create a Repo Tutorial: http://help.github.com/create-a-repo/

        需要指出的是这些教程使用的是msysgit提供的git bash,如果大家对命令行很感冒,那么那些教程基本上就够大家参考了,无需再浏览本文;否则恳请各位继续欣赏下文。

3 环境配置

        本着学习的态度,我按照上述教程走了一下,发现问题:github ssh: connect to host github.com port 22

本人愚钝,没有解决该问题……于是还是回到开始的想法,使用TortoiseGit管理自己的Github项目。

3.1 在TortoiseGit配置MSysGit

       在开始菜单中找到TortoiseGit的Settings一项,如图1所示。

image

图 1 TortoiseGit中Settings的位置

 

由于我是64位的电脑,所以会显示Settings (64 bit)。左键点击后,进入TortoiseGit的设置界面。可以清楚的看到,MSysGit已经配置好了。如果Git.exe的位置为空,请大家自己手动设置好。

2011-06-23_013648

图 2 TortoiseGit的设置界面

 

3.2 建立测试项目HelloGit

        在想放置项目的位置新建一个文件夹,名称为HelloGit,右键单击该文件夹,选择"Git Create repository here…",也就是创建本地的代码库。此时会弹出对话框,选择"OK"。(PS:不用搭理哪个复选框)随后会提示成功创建了一个空的代码仓库。

2011-06-23_014923

2011-06-23_015119

3.3 向HelloGit添加文件并更新项目到本地版本库中

        新建一个README文件,随意填写一些信息。然后邮件单击README,选择"Git Add…",就是将README文件添加到本地HelloGit项目中。

2011-06-23_015611

单击"OK"后,显示如下对话框。2011-06-23_015757

单击"commit",将更新提交到本地版本库中。

2011-06-23_020039

别忘了在"Message"中填写此次提交所完成的任务,便于以后查看提交信息,对项目的进度有所掌握。单击"OK",继续。

2011-06-23_020315

3.4 建立沟通远程版本库与TortoiseGit的联系

        这里提到的沟通桥梁就是通信中使用的密钥。TortoiseGit 使用扩展名为ppk的密钥,而不是ssh-keygen生成的rsa密钥。也就是说使用ssh-keygen -C "[email protected]" -t rsa产生的密钥在TortoiseGit中不能用。而基于github的开发必须要用到rsa密钥,因此需要用到TortoiseGit的putty key generator工具来生成既适用于github的rsa密钥也适用于TortoiseGit的ppk密钥。

        运行TortoiseGit开始菜单中的puttygen程序,点击“Generate”按钮,鼠标在上图的空白地方来回移动直到进度条完毕,就会自动生一个随机的key。

2011-06-23_022220

        登录Github官网,点击右上角的"Account Settings",选择SSH Public Keys->Add another public key,将上面生成的Key粘贴进来,选择"Add Key"。公钥添加完毕。然后点击上面对话框中的"Save private key",将私钥保存在本地,文件后缀是ppk。

        运行TortoiseGit开始菜单中的Pageant程序,程序启动后将自动停靠在任务栏中,图标显示为64 under windows 7 TortoiseGit used successfully configured Github server - Deva - text Martialism,双击该图标,弹出key管理列表。点击"Add Key",选择刚才保存的ppk文件,这样私钥就添加到key管理列表中了。

3.5 更新项目到远程版本库中

        这是我们的最后一步啦!但是前提是我们得在TortoiseGit中配置好"Remote"。右键单击HelloGit项目,选择TortoiseGit->Settings,弹出如下对话框。

2011-06-23_020904

        我们需要做的工作就是配置Git的Remote项。

Remote就是给该项目起个名称,我们就是HelloGit;

Url就是Github上对应的远程版本库的网络地址。各位有没有认真看前面给的教程呀,建立一个Repo应该没有问题吧。在本地key管理列表添加好自己的私钥了吧,在github上的相应项目中添加好自己的公钥了吧,那我们可以继续了,不然还得返回到3.4。在网站上进入你的项目中,会看到如下信息:

2011-06-23_023357

前面我已经讲了,在我的电脑上使用SSH,无法连接到github,所以此处我选择的是HTTP的方式。[email protected]:username/reponame.git就是我们需要的Url。(PS:username和reponame应该是跟你的设置对应的,在使用中你可别真的原封不动地使用[email protected]:username/reponame.git,这可是连不上服务器的)

Putty处需要填的信息就是我们在本地保存的私钥文件的路径。

        填好这三项后,点击"Add New",就会在左边的列表中显示我们添加好的Remote信息。好了,我们可以进行最后一项工作了。右键单击项目HelloGit文件夹,选择TortoiseGit->Push,弹出对话框,选择刚才添加的Remote信息,单击"OK",成功推送!

2011-06-23_024539



Reproduced in: https: //www.cnblogs.com/thirstycoder/p/3687141.html

Guess you like

Origin blog.csdn.net/weixin_34337265/article/details/93371096