"git log -- file_name" 显示小于 "git log --first-parent -- file_name"
"git log -- file_name" shows less than "git log --first-parent -- file_name"
在删除文件的地方进行合并后,"git log -- file_name" 没有显示当前分支的提交。但是,如果我执行 "git log" 或 "git log --first-parent -- file_name",提交就会出现。为什么?
重建步骤:
git init
echo "First" > file1.txt
git add file1.txt && git commit -m "Adding file1.txt"
echo "Second" > file2.txt
git add file2.txt && git commit -m "Adding file2.txt"
git checkout -b side_branch
echo "... and third" >> file1.txt # modifying file1.txt in side_branch
git commit -am "*** Adding third to file1.txt in side_branch"
git checkout master
git rm file1.txt && git commit -m "Removing file1.txt in master"
git checkout side_branch
git merge master
git rm file1.txt && git commit --no-edit
git log -- file1.txt # Doesn't show commit with ***
git log # Shows commit with ***
git log --first-parent -- file1.txt # Shows commit with ***
git log --follow -- file1.txt # Shows commit with ***
我认为日志命令的 --first-parent 版本会显示第一个日志命令列出的提交的子集,但事实并非如此。
我的猜测是默认的 History Simplification 算法意识到更改与 master 的合并无关。如果你明确地关闭简化,你会得到你所期望的:
git log --full-history -- file1.txt # Shows commit with ***
在删除文件的地方进行合并后,"git log -- file_name" 没有显示当前分支的提交。但是,如果我执行 "git log" 或 "git log --first-parent -- file_name",提交就会出现。为什么?
重建步骤:
git init
echo "First" > file1.txt
git add file1.txt && git commit -m "Adding file1.txt"
echo "Second" > file2.txt
git add file2.txt && git commit -m "Adding file2.txt"
git checkout -b side_branch
echo "... and third" >> file1.txt # modifying file1.txt in side_branch
git commit -am "*** Adding third to file1.txt in side_branch"
git checkout master
git rm file1.txt && git commit -m "Removing file1.txt in master"
git checkout side_branch
git merge master
git rm file1.txt && git commit --no-edit
git log -- file1.txt # Doesn't show commit with ***
git log # Shows commit with ***
git log --first-parent -- file1.txt # Shows commit with ***
git log --follow -- file1.txt # Shows commit with ***
我认为日志命令的 --first-parent 版本会显示第一个日志命令列出的提交的子集,但事实并非如此。
我的猜测是默认的 History Simplification 算法意识到更改与 master 的合并无关。如果你明确地关闭简化,你会得到你所期望的:
git log --full-history -- file1.txt # Shows commit with ***