Finding what branch a Git commit came from

后端 未结 14 2653
失恋的感觉
失恋的感觉 2020-11-22 10:43

Is there a way to find out what branch a commit comes from given its SHA-1 hash value?

Bonus points if you can tell me how to accomplish this using Ruby Grit.

14条回答
  •  北荒
    北荒 (楼主)
    2020-11-22 11:18

    For example, to find that c0118fa commit came from redesign_interactions:

    * ccfd449 (HEAD -> develop) Require to return undef if no digits found
    *   93dd5ff Merge pull request #4 from KES777/clean_api
    |\
    | * 39d82d1 Fix tc0118faests for debugging debugger internals
    | * ed67179 Move &push_frame out of core
    | * 2fd84b5 Do not lose info about call point
    | * 3ab09a2 Improve debugger output: Show info about emitted events
    | *   a435005 Merge branch 'redesign_interactions' into clean_api
    | |\
    | | * a06cc29 Code comments
    | | * d5d6266 Remove copy/paste code
    | | * c0118fa Allow command to choose how continue interaction
    | | * 19cb534 Emit &interact event
    

    You should run:

    git log c0118fa..HEAD --ancestry-path --merges
    

    And scroll down to find last merge commit. Which is:

    commit a435005445a6752dfe788b8d994e155b3cd9778f
    Merge: 0953cac a06cc29
    Author: Eugen Konkov
    Date:   Sat Oct 1 00:54:18 2016 +0300
    
        Merge branch 'redesign_interactions' into clean_api
    

    Update

    Or just one command:

    git log c0118fa..HEAD --ancestry-path --merges --oneline --color | tail -n 1
    

提交回复
热议问题