简体   繁体   中英

Git: How to find when a commit was merged into master?

I want to create a metric in my project that measures how long does a commit take from its creation till to get into the master branch?

Is it possible? It looks like for fast-forwarded commits I can't get this info from the git log.

If I can get a snapshot of the repository X days ago, maybe I can calculate it. Another option is to get a log that registers when a branch HEAD was modified.

Update: If you create an annotated tag at each release, you can just see the date of the tag that included the commit. Here is how to list the commits included in a tag

It is not easy, considering the commit itself does not know in which branch it is.
It does not keep track of branch "events" which would mention it was created in branch X, and then merge (possibly fast-forward) in branch Y.

Only git reflog registers HEAD changes, but it is limited in time .

As mentioned by the OP, you need to add a metadata (like an annotated tag , but you could also consider a git notes ) in order to memorize the information you need.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM