Why does git log not default to git log --follow?

前端 未结 2 1475
时光说笑
时光说笑 2021-02-12 17:59

If we ever moved a file to a different location or renamed it, all its previous history is lost in git log, unless we specifically use git log --follow

2条回答
  •  滥情空心
    2021-02-12 18:17

    Note: starting git 2.6 (Q3 2015), git log can follow the history by default for a file!

    See commit 076c983 (08 Jul 2015) by David Turner (dturner-tw).
    (Merged by Junio C Hamano -- gitster -- in commit 2dded96, 03 Aug 2015)

    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
    

    Note: there is also a (strangely not documented still in 2020 and Git 2.25) --no--follow option, which can override a log.follow config setting.
    Vser is proposing a patch.
    Jeff King (peff) points out the same commit I mentioned in the discussion: commit aebbcf5, Git 1.8.2, Sept. 2012, where --no-follow was introduced.

提交回复
热议问题