In git, how can I find the revision at which a branch was created?

前端 未结 4 1885
臣服心动
臣服心动 2020-12-14 18:55

UPDATE: example repository, https://github.com/so-gitdemo/so-gitdemorepo

In the context of the github repo. How can I easily locate rev \"b0430cee\"? I know I can ju

4条回答
  •  無奈伤痛
    2020-12-14 19:46

    Perhaps I misunderstand the question, but branches are defined by the commit at their tip, and every ancestor of that commit is contained in the branch. For example, suppose emergency-bug-fix is a branch whose tip is at Emergency bug fix in your diagram - the oldest commit on that branch will be The past (master). The "revision at which a branch was created" isn't a well-defined concept if you just look at the commit graph.

    If you're just concerned about when a branch was created in a particular repository, you could use the "reflog" - for example, look at the last line in the output of:

    git reflog show emergency-bug-fix
    

    However, the results from that command will be different from repository to repository, depending on when the ref was created there, for example by fetching or pushing. Also, by default the reflog expires entries after 90 days, it may not have that information any more. If you have a blessed central repository, you could do the try the same there, and that might give you the commit where that ref was first created in the centralized repository. I don't think that's the solution you want, however.

    As you've correctly worked out, it's a better idea to just tag points in the commit graph that you're interested in. Magnus Skog's answer tells you how to do that.

提交回复
热议问题