二、在Windows上的使用Git
不得不说,Git是为Linux而生的。(废话,Git的最初创建人就是Linux的创始人啊)。在Linux环境下,要使用Git,与任何Linux中的命令行工具没有什么区别。甚至在击键数上还有明显的优势。在Windows上要使用Git在目前看来只有两种方法:使用Cygwin(一个在Windows上运行的Linux环境)或者使用msysgit(http://code.google.com/p/msysgit/)。Cygwin和msysgit的使用方法类似。Cygwin具有大量Linux的功能,如果只是想使用Git功能的话msysgit还是最简单和快速的方法。下面的介绍将以msysgit为主进行。
为了能够具备通过互联网实现与别人协作开发的能力。对于项目,需要一个公开的源代码托管服务。好在,现在已经有不少可以供我们选择的。尤其是githost,更是一个中文的源代码托管服务提供方。从目前看来,在Githost上落户的项目还很少,貌似是一个新近诞生的服务提供方。如果项目对服务提供的稳定性有比较高的要求的话,还是选择较老的git源代码托管服务比较好吧。
如果是在局域网内工作的小组,要使用Git做源代码管理,那就更简单了,大家安装好自己的Git,并指定一个人负责对Git版本库进行管理就好了。
(一) GitHub简介
GitHub是使用Ruby开发的,具有清爽的界面。GitHub提供免费的源代码库托管,同时也提供付费的托管服务。通过付费私有库托管服务在财务上支持免费部分的持续运营。
GitHub提供了一套独特的代码库管理界面功能,并提供项目Wiki的能力。
GitHub提供了一系列的指南,也可以到这里去看看:http://github.com/guides/home
(二) 在Windows系统上安装Git
到msysgit的老家下载安装程序。http://code.google.com/p/msysgit/
选择下载“** Full installer if you want to use official Git 1.5.6.1 **”对应的Git-1.5.6.1-preview20080701.exe。实际上,总可以选择最新的Git版本,以取得更好的使用效果。
安装的过程很简单,基本上可以使用默认设置。只是在设置路径的时候要注意一下,为了避免与Windows路径导致的意外情况,还是使用“Use Git Bash Only”比较安全。
Msysgit有命令行和图形UI两种使用方式。根据你的喜好选择吧。要说的是,图形UI可能不能完成所有的工作,因此在某些情况下(例如创建SSH Key),命令行还是必不可少的。
Msysgit的Bash命令行对中文的支持不好。所有的中文字符都显示成了“?”。因此,为了避免麻烦,最好避免使用中文的文件名、目录名和用户名等。不知道现阶段Cygwin对中文的支持如何,随后再试试看吧。
(三) 设定GitHub
要使用GitHub首先需要创建SSH Key。SSH将用来加密本机与远端服务器之间的通信。同时也是识别你对代码所做的变更的方法。SSH Key可以使用Git命令行来产生。如果你已经有一个SSH Key了,那么在这里也可以直接使用。
要使用Git创建SSH Key 首先需要打开Git Bash 命令行。
输入命令:
ssh-keygen -C "username@email.com" -t rsa
说明:username@email.com 需要更换成你自己的Email地址
程序将提出一些问题,接受文件默认存放位置,当要求输入pass phrase时,如果本机安全没有问题,也可以不输入。找到当时制定的文件存储位置中id_rsa.pub文件。这就是在GitHub上申请帐户时需要使用的SSH公钥文件。
在github.com的register中选择Free account,在后续的界面中按照要求填入相应的内容即可完成注册。很简单的。
关于Git后续如何使用,还是在另外的文档中说明吧。 三、关于Git的一些联结
1、 建立Git远程服务器:
目前貌似还没有在Windows上建立Git服务器的。Linux在开源上还是强大啊!
l Hosting Git repositories, The Easy (and Secure) Way
http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way
l Remote Git Repos on Ubuntu: The Right Way
http://blog.drewolson.org/2008/05/remote-git-repos-on-ubuntu-right-way.html
l Installing Git on a server (Ubuntu or Debian)
http://www.urbanpuddle.com/articles/2008/07/11/installing-git-on-a-server-ubuntu-or-debian
2、 基于Git的源代码托管
l 中文的Git源代码托管,基于gitorious构建:http://www.githost.cn/projects
l Gitorious
Gitorious is another free hosting site with a custom web interface, supporting multiple repositories per project, local installations and with open source code:
http://gitorious.org/
l repo.or.cz
repo.or.cz is the oldest hosting site, accommodating many hundreds of projects, with open-sourced infrastructure and aimed at open source software. It provides full push features as well as simple mirroring mode and gitweb interface with various enhancements. :http://repo.or.cz/
l GitHub
GitHub provides both free hosting for smaller projects and paid options for private hosting and large-sized projects. It uses a custom web interface including a wiki hosting and puts emphasis on social networking of project developers:http://github.com/
3、 关于Git的有用的联结:
l Git的老家:http://git.or.cz/
l Git User's Manual (for version 1.5.3 or newer) :
http://www.kernel.org/pub/software/scm/git/docs/v1.6.0.2/user-manual.html
l Git - SVN Crash Course:
http://git.or.cz/course/svn.html
l Everyday GIT With 20 Commands Or So:
http://www.kernel.org/pub/software/scm/git/docs/everyday.html 四、参考文档:
l Getting Started with Git and GitHub on Windows:
http://kylecordes.com/2008/04/30/git-windows-go/
l 中文教程: http://www.b***/documents/gittutorcn.htm
l 简介: http://linuxtoy.org/archives/git.html
l 英文教程:http://www.kernel.org/pub/software/scm/git/docs/tutorial.html
l GitHub:http://github.com