Compare commits
29 Commits
hello_1.0
...
6a398dcde8
Author | SHA1 | Date | |
---|---|---|---|
6a398dcde8 | |||
f9e486b837 | |||
37a4decc83 | |||
f2dd2b6d5c | |||
ca358d7dcb | |||
572f5215ce | |||
9d867fc271 | |||
515dd2b9c4 | |||
7fca44eac8 | |||
ce2b85da59 | |||
df3218e422 | |||
73624ddf35 | |||
a4039843d6 | |||
a8029669af | |||
7952818907 | |||
15c0ebbff6 | |||
61d0e63490 | |||
c6700dec10 | |||
7476f0a141 | |||
51bc20bac1 | |||
81d8e86df1 | |||
570f8b26ee | |||
e8a66d4e72 | |||
5032b7e8f1 | |||
21e8c37152 | |||
659bfc6fbc | |||
22908a85ac | |||
07d5cbd029 | |||
17844d154a |
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
*.swp
|
||||
*.h
|
||||
hello
|
||||
*.pyc
|
1
Morgen.txt
Normal file
1
Morgen.txt
Normal file
@@ -0,0 +1 @@
|
||||
Guten Morgen
|
1
notes/.gitignore
vendored
Normal file
1
notes/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*.pyc
|
@@ -1,6 +1,6 @@
|
||||
## 2.7 Git Basic Ops
|
||||
|
||||
## 2.7.1 git tag
|
||||
### 2.7.1 git tag
|
||||
|
||||
给当前的进度打个标签
|
||||
```bash
|
||||
@@ -8,7 +8,7 @@ git tag -m "some message" <version-string>
|
||||
git describe # 查看标签
|
||||
```
|
||||
|
||||
## 2.7.2 Git 删除文件
|
||||
### 2.7.2 Git 删除文件
|
||||
git
|
||||
|
||||
```bash
|
||||
@@ -26,3 +26,71 @@ git ls-files --with-tree=HEAD^ # 父节点中的文件还在
|
||||
git add -u #将版本库中的本地文件的变更记录到暂存区中
|
||||
```
|
||||
|
||||
### 2.7.3 恢复删除的文件
|
||||
|
||||
```bash
|
||||
git cat-file -p HEAD~1:filename > filename
|
||||
```
|
||||
|
||||
### 2.7.4 移动文件
|
||||
|
||||
```bash
|
||||
git mv welcome.txt README # git提供的git mv来移动文件
|
||||
git commit -m "rename test" # 在输出的结果中可以查看改名前后两个文件的相似度
|
||||
```
|
||||
|
||||
### 2.7.5 显示版本号
|
||||
|
||||
```bash
|
||||
git describe # 展示版本号
|
||||
```
|
||||
|
||||
```bash
|
||||
git log --oneline --decorate -4 #在提交日志中显示提交对应的Tag
|
||||
```
|
||||
|
||||
### 2.7.6 git add -i
|
||||
|
||||
```bash
|
||||
git add -i #进入一个交互式的提交脚本
|
||||
```
|
||||
|
||||
### 2.7.8 Git忽略
|
||||
|
||||
就是编辑.gitignore文件
|
||||
|
||||
可以设置全局忽略的文件位置
|
||||
|
||||
```bash
|
||||
git config --global core.excludesfile /path/to/file
|
||||
git config core.excludesfile
|
||||
```
|
||||
|
||||
小trick,可以用cat快速写入一个文件
|
||||
```bash
|
||||
cat > .gitignore << EOF
|
||||
hello
|
||||
*.o
|
||||
*.h
|
||||
EOF
|
||||
```
|
||||
|
||||
忽略语法
|
||||
```text
|
||||
# 这是注释行 —— 被忽略
|
||||
*.a # 忽略所有以 .a 为扩展名的文件。
|
||||
!lib.a # 但是 lib.a 文件或者目录不要忽略,即使前面设置了对 *.a 的忽略。
|
||||
/TODO # 只忽略根目录下的 TODO 文件,子目录的 TODO 文件不忽略。
|
||||
build/ # 忽略所有 build/ 目录下的文件。
|
||||
doc/*.txt # 忽略文件如 doc/notes.txt,但是文件如 doc/server/arch.txt 不被忽略。
|
||||
```
|
||||
|
||||
### 2.7.9 Git Archive
|
||||
|
||||
```bash
|
||||
git archive -o latest.zip HEAD # 根据最新的提交创建zip
|
||||
git archive -o latest.zip HEAD src doc # 只将目录src doc放入zip中
|
||||
git archive --format=tar --prefix=1.0/ v1.0 | gzip > foo-1.0.tar.gz
|
||||
```
|
||||
|
||||
|
||||
|
152
notes/2.8-git-gui.md
Normal file
152
notes/2.8-git-gui.md
Normal file
@@ -0,0 +1,152 @@
|
||||
## 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. 添加删除操作到暂存区
|
||||
3. 有一个前提是文件必须已经被git所跟踪
|
||||
|
||||
`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
|
||||
|
||||
显示提交历史
|
||||
|
||||
参数代表版本范围
|
||||
|
||||
```bash
|
||||
git log --oneline F^! D
|
||||
```
|
||||
**graph show**
|
||||
```bash
|
||||
git config alias.glog "log --graph"# 用别名
|
||||
git glog --oneline
|
||||
```
|
||||
|
||||
显示最近几条
|
||||
```bash
|
||||
git log -3 --pretty=oneline
|
||||
```
|
||||
|
||||
显示提交的具体改动
|
||||
```bash
|
||||
git log -p -1
|
||||
```
|
||||
|
||||
显示变更概要
|
||||
```bash
|
||||
git log --stat --oneline I..C #显示版本I到C的变更概要
|
||||
```
|
||||
|
||||
显示参数
|
||||
```bash
|
||||
git log --pretty=raw -1 # 显示提交的原始数据,
|
||||
git log --pretty=fuller -1 # 显示作者和提交者
|
||||
git log --pretty=oneline # 提供最精简的日志输出
|
||||
```
|
||||
|
||||
只是查看,分析某一次的提交,可以使用`git show`或者是`git cat-file`命令
|
||||
```bash
|
||||
git show D --stat # 展示里程碑D及其提交
|
||||
git cat-file -p D^0 # 展示里程碑D及其提交
|
||||
```
|
||||
|
||||
### 2.8.4.4 git diff
|
||||
|
||||
```bash
|
||||
git diff B A # 比较B和A里程碑
|
||||
git diff A # 比较工作区和里程碑A
|
||||
git diff --cached A
|
||||
git diff
|
||||
git diff --cached
|
||||
git diff HEAD
|
||||
```
|
||||
|
||||
```bash
|
||||
git diff --word-diff
|
||||
```
|
||||
|
||||
### 2.8.4.5 git blame
|
||||
|
||||
可以追溯指出是谁在什么时候,什么版本引入的代码
|
||||
|
||||
```
|
||||
git blame <filename>
|
||||
git blame -L <n,m> <filename> # 查看某几行
|
||||
```
|
||||
|
||||
### 2.8.4.6 git bisect
|
||||
|
||||
用于二分查找什么时候引入的代码
|
||||
```bash
|
||||
git bisect start # 开始二分查找
|
||||
git bisect bad # 设置当前版本为坏版本
|
||||
git bisect good G # 设置里程碑G为好版本
|
||||
git bisect reset # 结束
|
||||
```
|
||||
|
||||
标记错误,恢复
|
||||
```bash
|
||||
git bisect log > logfile # 打开logfile,删除标记错误的行
|
||||
git bisect reset
|
||||
git bisect replay logfile # 用logfile恢复进度
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#ifndef HELLO_WORLD_VERSION_H
|
||||
#define HELLO_WORLD_VERSION_H
|
||||
|
||||
#define _VERSION "old_practise"
|
||||
#define _VERSION "<version>"
|
||||
|
||||
#endif
|
1
welcome.txt
Normal file
1
welcome.txt
Normal file
@@ -0,0 +1 @@
|
||||
Hello world
|
Reference in New Issue
Block a user