SVN属于集中式版本管理系统,CVS的前身,要求使用者和版本控制服务器要有网络。
Git属于分布式版本控制器,Linux创始人Linus反向工程了分布式版本控制的商业软件BitKeeper,主要优势:所有操作都可在本地完成,执行效率高,方便多人协同工作。
典型的组合:msysgit/Cygwin + TortoiseGit
Server端配置方式:
Setup a Git repository: server side
•Create an empty directory:
–$mkdir test.git
•Initialize a Git repository:
–$cd test.git
–$git init –bare –shared
•Write down the path of this repository:
–like: /home/git/test.git
–or: /home/jacoxu/git/test.git
Client端配置方式:
•Initialize a local repository:
–$cd workspace/test [the home directory of a project]
–$git init
•Create the first commit:
–$git add . [add all files to commit]
–$git commit -m “the first commit”
•Add the info of the remote repository:
–$git remote add origin ssh://git@192.168.0.1:47/home/jacoxu/git/test.git
•Upload the project to server:
–$git push origin master
–Password: jac**
•Or Download an existed remote repository:
–$git clone ssh://git@192.168.0.1:47/home/jacoxu/git/test.git
Others:
•设置用户名和密码:
–$git config –global user.name “jacoxu”
–$git config –global user.email jacoxu1987@gmail.com
•查看谁完成的提交:
–$git log –pretty==fuller
•查看当前有那些文件被修改了:
–$git status -s
•添加一个新的远程库:
–$git remote add jacoxu-remote ssh://root@192.168.9.236:22/u11/20140625Git-jacoxu/jacoxu-bak.git
•查看当前注册的远程库有哪些:
–$git remote -v
•Upload the project to server:
–$git push origin master
–Password: jac**
•Upload the project from server:
–$git pull origin master
–Password: jac**
•修改远程库URL地址:
–$git remote set-url jacoxu-remote ssh://git@192.168.0.1:47/home/jacoxu/git/test2.git
•修改远程库Name:
–$git remote rename jacoxu-remote jacoxu-remote2 (不建议操作默认远程库origin)
•Suse 11 服务器安装Git方法:
–Step.1: 下载git-1.7.9.4.tar.gz
–Step.2: 解压:$tar -xvf git-1.7.9.4.tar.gz
–Step.3: 进入解压后的目录:$cd ./git-1.7.9.4/
–Step.4: 执行如下指令:$./configure
–Step.5: 执行如下指令:$./make
可能会出现如下错误:
GIT_VERSION = 1.7.3.4
* new build flags or prefix
CC fast-import.o
In file included from builtin.h:6,
from fast-import.c:147:
cache.h:17:18: error: zlib.h: No such file or directory
–Step.6: 下载安装包zlib-devel-1.2.3-3.x86_64.rpm
–Step.7: 安装RPM:$sudo rpm -ivh zlib-devel-1.2.3-3.x86_64.rpm
–Step.8: 再次执行如下指令:$make && make install
–Step.9: 验证是否安装成功:$git –version
输出显示:git version 1.7.9.4
本地Shell进入服务器的SSH指令为:$ ssh root@192.168.9.236 -p 22