在 git 中,如何找到创建分支的修订版? [英] In git, how can I find the revision at which a branch was created?

查看:22
本文介绍了在 git 中,如何找到创建分支的修订版?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:示例存储库,https://github.com/so-gitdemo/so-gitdemorepo

在 github 存储库的上下文中.如何轻松找到 revb0430cee"?我知道我可以看看,但这个存储库模仿的真实示例有十几个提交者和多个其他分支.不太容易使用检查.

In the context of the github repo. How can I easily locate rev "b0430cee"? I know I can just look, but the real example that this repository mimics has a dozen committers and multiple other branches. Not quite as easy to use inspection.

分支被多次合并后,如何找到分支创建修订版?

How can I find the branch creation revision when the branch has been merged multiple times?

我知道这个问题:如何确定 Git 分支的创建时间?

该解决方案似乎不适用于已多次合并的分支.我们通常将错误修复从发布分支合并回主分支.也许我们甚至在这部分做错了......对 git 来说还是新手.

The solution does not appear to work for a branch that has been merged multiple times. We typically merge bug fixes back from the release branch to the main branch. Maybe we're even doing this part wrong ... still new to git.

想象一下下面的简单情况.真实的东西有更多人对主/分支的提交.还有几个发布分支(想想 1.0、1.1、1.2、1.3)

Imagine the following simple. The real thing has MANY more commits on master/branch from multiple people. There are also several release branches (think 1.0, 1.1, 1.2, 1.3)

        Future dev  ?
                    |
                    |
   Merge 1.0 back   *  ? Potential future fixes
                    | |
                    | |  
                    |  
           New work *  |
                    |  * Emergency bug fix
                    |  |
   Merge 1.0 back   *  |
                    | |
                    | |
                    |  * Another bug fix
                    |  |
                    |  |
        New feature *  * First bugfix on branch 1.0
                    |  /
                    | /
                    |/
                    * Feature
                    |
                    |
                    |
                    * Some  feature
                    |
                    |
                    |
                    * The past (master)

我们仍然是 git 的新手,正在寻找管理版本和分支的最佳方法,我们决定需要追溯性地向 repo 添加一些标签.例如 1.0 标记用于 1.0 分支的开始,随后 1.0.1 标记用于修正版本.

We're still new to git and working out the best way to manage releases and branches and we've decided that we need to retroactively add some tags to the repo. Such as a 1.0 tag for the beginnning of the 1.0 branch and later 1.0.1 tags to bugfix releases.

后续奖励问题:添加我想要的标签的最佳方式是什么?我应该标记哪个版本?第一次提交新分支?还是分支提交之前的第一次共同提交?

Follow-up bonus question: What is the best way to add the tags that I want? and at which revision should I tag? first commit on new branch? or first common commit before branch commit?

推荐答案

自从你添加了一个 git repo...我远程工作来测试.

Since you added a git repo... I worked remotely to get things tested.

如何轻松找到 rev "b0430cee"?

How can I easily locate rev "b0430cee"?

在这种情况下,这个漂亮的 oneliner 为我完成了这项工作:

In that case, this pretty oneliner did the job for me:

git rev-list --reverse --topo-order --left-right --boundary 1.0...master | 
    grep "^>" -B1 |
    head -1 |
    cut -c2-

如果您想获得 469c14a1fa8a40237700(新功能工作),这对我有用:

If you wanted to get 469c14a1fa8a40237700 (New feature work) instead, this works for me:

git rev-list --reverse --topo-order --left-right --boundary 1.0...master | 
    grep "^>" |
    head -1 |
    cut -c2-

HTH

这篇关于在 git 中,如何找到创建分支的修订版?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆