GIT 常用命令

1.创建初始化版本库

1
git init

2.将文件添加到版本库中

1
2
3
4
5
git add index.html (添加到暂存区)
 
git add . 命令让Git把当前目录及目录中的文件都添加到版本库里
 
git commit -m 'test'  添加到版本库

3.查看提交历史

1
2
3
4
5
git log
 
git show header id
 
git show-branch --more=10 当前开发分支简介的单行摘要

4.查看提交差异

1
git diff  id1 id2 (git diff 显示仍留在工作目录中且未暂存的变更)
1
git diff --cached (显示已经暂存并且因此要有助于下次提交的变更)

5.使用散列值把文件内容从对象库里提取出来

1
2
$ git cat-file -p ce013625030ba8dba906f756967f9e9ca394464a
hello

6.通过对象的唯一前缀来查找对象的散列值

1
2
$ git rev-parse ce013
ce013625030ba8dba906f756967f9e9ca394464a

 7.

参考资料:《Git版本控制管理》

原文地址:https://www.cnblogs.com/liuhaobin/p/10790428.html