Tanky WooRSS

Git版本控制系统

23 Dec 2011
这篇博客是从旧博客 WordPress 迁移过来,内容可能存在转换异常。

一些概念的介绍:

版本控制系统:

版本控制Revision control)是维护工程蓝图的标准作法,能追踪工程蓝图从诞生一直到定案的过程。此外,版本控制也是一种软件工程技巧,借此能在软件开发的过程中,确保由不同人所编辑的同一程式档案都得到同步。

(更多见wiki:http://zh.wikipedia.org/wiki/%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6)

Git:

Git 是一个由林纳斯·托瓦兹为了更好地管理linux内核开发而创立的分布式版本控制/软件配置管理软件。需要注意的是和GNU Interactive Tools,一个类似Norton Commander界面的文件管理器相区分。

(更多见wiki:http://zh.wikipedia.org/wiki/Git , 另外推荐一本在线教程《Pro Git》:http://progit.org/book/zh/ ,感谢肉山的教程:http://blog.meathill.net/tech/devtools/version-management-with-tortoisegit-msysgit-github.html)

Github:

GitHub 是一个用于使用Git版本控制系统的项目的基于互联网的存取服务。它是由GitHub公司(先前被称作用Logical Awesome)的开发者Chris Wanstrath, PJ Hyett, 和 Tom Preston-Werner 使用Ruby on Rails写成的。GitHub同时提供商业账户和为开源项目提供的免费账户。

(更多见wiki:http://zh.wikipedia.org/wiki/GitHub)

(PS:维基百科是个好东西,大家要珍惜,尤其下面经常给出一些额外的教程,都很经典。)


关于msysGit的安装:

在Windows下,我选择了安装msysGit,它的介绍及下载地址:http://code.google.com/p/msysgit/

安装过程有以下几个地方需要注意:

关于Git Bash复制和粘贴的问题:

git_install

看见Freewind写的教程推荐2,3项,原因是因为无法复制,其实是可以复制的,安装完打开Git Bash,点击左上角的图标,选择默认值,把"快速编辑模式"勾上。关闭后再打开,右键就可以进行复制或粘贴了。(详细见:http://liuhui998.com/2010/09/26/msysgitwindowscopypaste/)

我copy下里面主要的一段:

> > With QuickEdit mode, you can copy text between a command window and Windows-based programs, and you can also paste text into a command window by using a right-click operation. In Microsoft Windows 2000, QuickEdit and Insert mode are both enabled by default. In Windows XP, because these features are disabled by default, there is improved program compatibility with older MS-DOS-based programs that have included mouse support. > > > > To enable QuickEdit mode in Windows XP: Click Start, click Run, type cmd, and then click OK. Click the icon in the upper-left corner of the Command Prompt window, and then click Properties. On the Options tab, click to select the QuickEdit Mode and Insert Mode check boxes. Click OK. Click Save properties for future windows with same title, and then click OK. > >

以上针对win7同样使用。

另外一个是:

git_install2

让我们选择如何处理文本文件中的选行符。git考虑到合作者可能在不同的操作系统下,如windows下使用\r\n,linux下使用\n,mac下使用\r。为了既能保证服务器上的代码使用相同的换行符,在各自的电脑上又能使用各自的换行符,所以有三种处理方式:

  1. 下载时把换行符变成\r\n,提交时变成\n

  2. 下载时不转换,提交时变成\n

  3. 下载和提交时都不处理

作为windows用户,我们应该选择第一项。(感谢Freewind的教程:http://freewind.me/blog/20110914/236.html)

安装完,打开Git Bash:

git_interface

至于Git GUI,打开了,随便瞄了一眼,过一会再研究下,Mark一笔。


关于Git的建立和配置:

官方教程:

http://help.github.com/win-set-up-git/

大概过程:

1.创建一个Github账号:

https://github.com/

2.新建一个仓库:

在左下角有一个Create a Repository,点击创建,会有一个提示安装:

git_setup副本

按照自己的提示来就行~~~


接着就是建立SSH Keys:

打开Git Bash,输入代码:

ssh-keygen -t rsa -C "your_email@youremail.com"

然后一路按Enter就行了,当然也可以自己设置密码:

QQ截图20111223095733

然后会再本地.ssh文件夹里生成idrsa和idrsa.pub文件,打开idrsapub文件,全部copy,然后在github网站打开”Account Settings” > Click “SSH Public Keys” > Click “Add another public key”,把复制的粘贴进去。

配置好后可以用:

ssh -T git@github.com

测试一下。

成功了会显示如上图。

(更多资料:http://help.github.com/ssh-issues/)


我把网上一些朋友的教程copy到word中打包上传了,大家也可以了下载了看看:

http://www.kuaipan.cn/index.php?ac=file&oid=35241628297854978

DATE:2011.12.23

By: Tanky Woo at 寝室