gpt4 book ai didi

git - 为什么 git log 不默认为 git log --follow?

转载 作者:IT王子 更新时间:2023-10-29 01:29:39 25 4
gpt4 key购买 nike

如果我们将文件移动到不同的位置或重命名它,它以前的所有历史记录都会在 git log 中丢失,除非我们专门使用 git log --follow .我认为通常,预期的行为是我们也希望看到过去的历史,而不是在重命名或移动后“切断”,所以 git log 没有默认的原因使用 --follow 标志?

最佳答案

注意:从 git 2.6(2015 年第 3 季度)开始,git log 可以默认跟踪文件的历史记录!

参见 commit 076c983 (2015 年 7 月 8 日)作者:David Turner (dturner-tw) .
(由 Junio C Hamano -- gitster -- merge 于 commit 2dded96 ,2015 年 8 月 3 日)

log: add "log.follow" configuration variable

People who work on projects with mostly linear history with frequent whole file renames may want to always use "git log --follow" when inspecting the life of the content that live in a single path.

Teach the command to behave as if "--follow" was given from the command line when log.follow configuration variable is set and there is one (and only one) path on the command line.

git config log.follow true

注意:还有一个(奇怪的是在 2020 年和 Git 2.25 中还没有记录)--no--follow 选项,它可以覆盖 log.follow 配置设置。
Vserproposing a patch .
Jeff King (peff) 指出了相同的提交 I mentioned in the discussion : commit aebbcf5 ,Git 1.8.2,2012 年 9 月,其中引入了 --no-follow

关于git - 为什么 git log 不默认为 git log --follow?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12150899/

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