设置
git version 2.11.0.windows.1
以下是一个bash代码片段,可以用来复制我的测试仓库:
git init
# Create a file
echo Hello > a.txt
git add a.txt
git commit -m 'First commit'
# Change it on one branch
git checkout -b feature
echo Hi > a.txt
git commit -am 'Change'
# Rename it on the other
git checkout master
git mv a.txt b.txt
git commit -m 'Move'
# Merge both changes
git merge --no-edit feature
在最后,
git log --graph --pretty=oneline --abbrev-commit
命令会输出以下内容:* 06b5bb7 Merge branch 'feature'
|\
| * 07ccfb6 Change
* | 448ad99 Move
|/
* 31eae74 First commit
问题
现在,我想要获取b.txt
文件的完整日志(例如-b.txt
)。
执行命令:git log --graph --pretty=oneline --abbrev-commit --follow -- b.txt
,输出结果如下:
...
* | 1a07e48 Move
|/
* 5ff73f6 First commit
正如您所看到的,尽管
Change
提交确实修改了文件,但该提交未列出。我认为这是由于
--graph
隐式使用--topo-order
导致的,因为添加--date-order
会将提交恢复,但这可能只是偶然。此外,添加
-m
显示合并提交(很好),以及Change
提交,但然后合并提交会重复。* 36c80a8 (from 1a07e48) Merge branch 'feature'
|\
| | 36c80a8 (from 05116f1) Merge branch 'feature'
| * 05116f1 Change
* | 1a07e48 Move
|/
* 5ff73f6 First commit
问题
我遇到了奇怪的行为,需要解释一下我错过了什么?
如何清晰地显示更改文件的所有提交记录,并跟踪重命名过程?