在删除文件的合并之后,“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 ***
我认为log命令的--first-parent版本会显示第一个log命令列出的提交的子集,但它不会。
答案 0 :(得分:3)
我的猜测是默认的History Simplification算法意识到通过来自master的合并使更改变得无关紧要。如果你明确地关闭了简化,你会得到你期望的结果:
git log --full-history -- file1.txt # Shows commit with ***