Skip to content

Commit b990a87

Browse files
JackLau1222CapableCCat
authored andcommitted
add git log --follow and git rebase -i --root intro
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
1 parent 82f4c06 commit b990a87

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

docs/Basic-Knowledge/Git_Command.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,23 @@ git shortlog
380380
git log -- README.md
381381
```
382382

383+
- `--follow`:跟踪文件的重命名历史,显示文件在重命名前后的所有提交。
384+
385+
```
386+
git log --follow <file>
387+
```
388+
389+
```
390+
# 查看文件的完整历史,包括重命名
391+
git log --follow --oneline src/main.cpp
392+
393+
# 查看文件的详细变更历史
394+
git log --follow -p config.json
395+
396+
# 查看文件的统计信息
397+
git log --follow --stat utils.py
398+
```
399+
383400
**3. 显示差异**
384401

385402
- `-p``--patch`:显示每个提交的详细差异。
@@ -779,6 +796,18 @@ git show <commit-hash>
779796
git rebase -i HEAD~3
780797
```
781798

799+
- 从根提交开始交互式变基(编辑整个提交历史):
800+
801+
```
802+
git rebase -i --root
803+
```
804+
805+
**使用场景**
806+
- 需要修改第一个提交(root commit)时
807+
- 想要重新组织整个仓库的提交历史
808+
- 清理项目初始阶段的混乱提交记录
809+
- 合并或删除早期的提交
810+
782811
##### 3. 解决冲突
783812

784813
- 在变基过程中,如果发生冲突,Git 会暂停并提示你解决冲突。

0 commit comments

Comments
 (0)