Git是一个开源的分布式版本控制系统,用以有效、高速的处理从很小到非常大的项目版本管理。
如果说Linus只做了两件事,那么第一件事是开发了Linux,第二件事就是开发了Git。
一、linux/ubuntu下的安装:
1、早期的版本使用命令:sudo apt-get install git-core
2、新版本安装使用命令:sudo apt-get install git
二、windows下的安装:
1、下载安装文件:
下载命令行客户端msysgit:http://code.google.com/p/msysgit/
下载图形界面工具TortoiseGit:http://code.google.com/p/tortoisegit/
2、先安装命令行客户端msysgit:
安装文件为:Git-1.8.4-preview20130916.exe
一路Next(除非你想改变安装路径)
3、再安装图形界面工具TortoiseGit:
安装文件为:TortoiseGit-1.8.6.0-32bit.msi
一路Next(除非你想改变安装路径)
4、针对英语没过CET4的哥,特提供人性关怀
安装中文补丁包(双击即可)
TortoiseGit-LanguagePack-1.8.6.0-32bit-zh_CN.msi
三、基本配置:
1、配置用户名,作为以后提交的作者:
git config --global user.name "your name"
2、配置邮箱,作为签署邮箱:
git config --global user.email “your email”
3、配置平台,不同平台对回车的处理不同,windows下必须将core.autocrlf选项配置为false:
git config --global core.autocrlf false
4、配置代理,针对使用代理上网的情况:
git config --global ssh.proxy 192.168.253.2:3128
git config --global http.proxy 192.168.253.2:3128
git config --global https.proxy 192.168.253.2:3128
5、git config选项说明:
--local:针对具体工程配置,影响工程目录下的/.git/config文件,优先级最高
--global:针对用户设置,影响~/.gitconfig文件,优先级次之
--system:针对系统配置,影响/etc/.gitconfig文件,优先级最低
四、基本命令:
1、版本库创建: # git init
2、文件添加: # git add file_name
3、提交: # git commit -m commit_log
4、版本库克隆: # git clone URL
5、版本库推送: # git push URL
6、分支创建: # git branch branch_name
7、分支切换: # git checkout branch_name
8、分支创建并切换: # git checkout -b branch_name
9、分支合并: # git merge branch_name