git-learner/notes/2.8-git-gui.md

56 lines
1.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## git UI
### 2.8.4 git rev-parse
```bash
git rev-parse --symbolic --branches # 显示分支
git rev-parse --symbolic --tags # 显示里程碑
git rev-parse --symbolic --glob=refs/* # 显示所有的引用
```
`git rev-parse`可以将一个Git对象表达式表示为对应的SHA1哈希值
tag也分为两种lightweighted tag和annotated tag
```bash
git tag <tagname> # lighteweighted tag
git tag -a <tagname> -m <message> # annotated tag
```
两种的区别在于轻量标签只会有commit对象
标记标签会自己生成一个对象然后指向commit对象
所以下面的内容中,`git rev-parse`指令的参数A和A^0是不同的哈希
```bash
git rev-parse master refs/heads/master # 显示多个哈希
git rev-parse A refs/tags/A
git rev-parse A^{} A^0 A^{commit}
git rev-parse A^3 # ~<n> = <n> ^
```
### git rm / git add -u / git rm --cached
`git rm`会执行两个指令:
1. 删除文件(工作区中的)
2. 添加删除操作到暂存区
`git add -u`是将工作区的已经被git跟踪的文件添加到暂存区,包括修改和删除
`git rm --cached`是将暂存区的移除出来,也就是让**Git停止跟踪文件**。也就是说如果文件之前已经在commit中无论文件是否被修改使用这个指令都能让Git停止跟踪文件
### 2.8.4.2 git rev-list
作用主要是研究不同版本之间的范围,主要就是哈希值
```bash
git rev-list --oneline A
git rev-list --oneline D F # 使用两个tag的并集
git rev-list --oneline ^G D # 排除这个版本和历史版本 等价于
git rev-list --oneline G..D # 连接两个版本
git rev-list --oneline B...C # 两个版本共同能够访问的除外
git rev-list --oneline B^@ # 提交的历史提交,自身除外
git rev-list --oneline B^! # 只看提交本身
```
### 2.8.4.3 git log