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

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

问题描述

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



在github回购的背景下。如何轻松找到revb0430cee?我知道我可以看看,但这个存储库模仿的真实例子有十几个提交者和多个其他分支。



如何在多次合并分支时找到分支创建版本?

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



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



想象一下下面的简单。真正的东西有来自多个人的主/分支上的更多提交。还有几个发布分支(认为1.0,1.1,1.2,1.3)

 未来开发? 
|
|
合并1.0返回*?潜在的未来修复
| \ |
| \ |
| \
新作品* |
| *紧急错误修复
| |
合并1.0返回* |
| \ |
| \ |
| *另一个bug修复
| |
| |
新功能* *第一个bug分支1.0
| /
| /
| /
*特征
|
|
|
*有些功能
|
|
|
*过去(主)

我们对git还是很陌生,管理发行版和分支机构的最佳方式,因此我们决定需要追溯性地向回购协议添加一些标签。例如1.0分支的1.0标签以及后来的1.0.1标签到bugfix版本。



后续奖励问题:添加最佳方式是什么我想要的标签?以及我应该在哪个版本上加标签?首先在新分支上提交?或者在分支提交之前的第一个常见提交?

解决方案

因为您添加了git repo ...我远程工作以测试事情。


如何轻松找到revb0430cee?

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

  git rev-list --reverse  - -topo-order  - 左右 - 边界1.0 ... master | 
grep^> -B1 |
head -1 |
cut -c2-

如果您想获得469c14a1fa8a40237700(新功能工作)相反,这适用于我:

  git rev-list --reverse  - -topo-order  - 左右 - 边界1.0 ... master | 
grep^> |
head -1 |
cut -c2-

HTH


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 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?

I am aware of this question: How to determine when a Git branch was created?

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.

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)

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?

解决方案

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

How can I easily locate rev "b0430cee"?

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-

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天全站免登陆