V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
5ispy
V2EX  ›  程序员

git 如何查看某个文件是什么时候 “来到” 当前这个分支的

  •  
  •   5ispy · Aug 19, 2020 · 2458 views
    This topic created in 2080 days ago, the information mentioned may be changed or developed.
    具体场景:有个分支 branch-a,里面有个文件 hello.java,现在想知道这个 hello.java 文件什么时候“来到”这个分支的。
    目前能想到两种情况:
    如果是某个人直接在这个分支新建的,怎么查出来是谁在什么时候新建的?
    如果是某个人把其他分支 merge 过来的,怎么查出来是谁在什么时候 merge 的,导致这个文件来到了当前这个分支?

    另外:
    IDEA 上查看 history,或者 git log,只能查看 commit 的记录,无法分辨是在这个分支新建的还是从别的分支 merge 过来的,
    4 replies    2020-08-19 17:29:11 +08:00
    DCCooper
        1
    DCCooper  
       Aug 19, 2020 via iPhone   ❤️ 1
    切到当前你要查看的分支,git blame hello.java
    momocraft
        2
    momocraft  
       Aug 19, 2020
    无法简单分辨
    分支不拥有 commit 。各种方法只能看到文件是从哪个 commit 开始存在的,无从知道那个 commit 当时是在哪个分支。
    msg7086
        3
    msg7086  
       Aug 19, 2020
    Blame 一路往上找。
    I2E
        4
    I2E  
       Aug 19, 2020
    git log -p
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1049 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 23:32 · PVG 07:32 · LAX 16:32 · JFK 19:32
    ♥ Do have faith in what you're doing.