Finding what branch a Git commit came from

后端 未结 14 2561
失恋的感觉
失恋的感觉 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:38

    To find the local branch:

    grep -lR YOUR_COMMIT .git/refs/heads | sed 's/.git\/refs\/heads\///g'
    

    To find the remote branch:

    grep -lR $commit .git/refs/remotes | sed 's/.git\/refs\/remotes\///g'
    

提交回复
热议问题