Git配置
安装
yum install git
全局配置
1 #设置提交用户名
2 git config --global user.name "leoxu"
3
4 #设置提交邮箱
5 git config --global user.email "xucongjie1990@gmail.com"
6
7 #设置分色显示
8 git config --global color.ui true
9
10 #验证全局配置
11 git config -l
基本命令
1 #初始化本地仓库
2 git init
3 git remote add origin git@xxxx.git
4 git add .
5 git commit
6 git push -u origin master
7
8
9 #clone 远程仓库
10 #Clone远程版本库
11 git clone git@115.28.73.167:wangcee/demo.git
12
13 #添加远程版本库origin
14 git remote add origin git@host:project.git
15
16
17git add README.md# 将工作文件修改提交到index (什么是Index,下页解释) git add . # 将所有修改过的工作文件提交到index
18git reset --hard <version> # 将本地文件空间恢复为指定的版本,同时修改所有的index及本地库 git reset (--soft | --mixed | --hard) <version> <file>
19git commit <file> #将修改提交到本地库
20git commit
21git commit -a # 将git add(或git rm)和git commit等操作都合并在一起做 git commit -am "some comments"
22
23git revert <version> # 撤销某次提交,撤销动作本身也创建了一次提交对象 git revert HEAD # 撤销最后一次提交
24
25
26
27 #基本diff
28 git diff <file> # 比较当前文件和index文件差异 git diff
29 git diff <V1> <V2> # 比较两次提交之间的差异 git diff --cached # 比较index与本地库差异
30 git diff HEAD #比较工作版本与HEAD(本地库)的差异
31
32
33 #提交记录
34 git log
35 git log <file> # 查看该文件每次提交记录
36 git log -p <file> # 查看每次详细修改内容的diff
37 git log -p -2 # 查看最近两次详细修改内容的diff