gpt4 book ai didi

git - "git log -- file_name"显示小于 "git log --first-parent -- file_name"

转载 作者:太空狗 更新时间:2023-10-29 14:45:43 34 4
gpt4 key购买 nike

在删除文件的地方进行 merge 后,“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 的 merge 无关。如果你明确地关闭简化,你会得到你所期望的:

git log --full-history -- file1.txt     # Shows commit with ***

关于git - "git log -- file_name"显示小于 "git log --first-parent -- file_name",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28610078/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com