简体   繁体   English

Git-svn非樱桃

[英]Git-svn unpicked cherries

Given a repository that was previously in SVN and has now been fully converted to Git (ie. currently accessed via "pure" git and not git svn ): 给定一个以前在SVN中的存储库,现在已完全转换为Git(即当前通过“纯” git而不是git svn ):

Given a mainline branch and a release branch that diverged from mainline prior to the Git conversion: 给定主线分支和发布分支在Git转换之前偏离主线:

Is there any easy way (from Git) to tell which commits are present on the release branch and not on the mainline branch (ie. possible candidates to be cherry-picked back to mainline, when a fix has been made directly to the release branch)? 是否有任何简单的方法(来自Git)来告诉哪些提交存在于发布分支而不是主线分支上(即,可能的候选者被挑选回主线,当直接修复发布分支时)?

The problem I see is that commands like git cherry (which is apparently the right choice for branches that diverged after the Git conversion) expect that complete commits are kept intact, but merges made in SVN prior to the conversion tend to be roll-ups -- basically squashed cherries instead of intact cherries. 我看到的问题是像git cherry这样的命令(显然是在Git转换分支的分支的正确选择)期望完整的提交保持不变,但是在转换之前在SVN中进行的合并往往是汇总 - - 基本上压扁樱桃而不是完整的樱桃。

In SVN, this is accomplished by inspecting the svn:mergeinfo property (usually automatically via tools). 在SVN中,这是通过检查svn:mergeinfo属性(通常通过工具自动完成)来完成的。 I don't know if this information was preserved during the conversion process, or if there are any tools that know to look for it in an apparently-native-Git repository. 我不知道在转换过程中是否保留了这些信息,或者是否有任何工具知道在一个看似本机的Git存储库中查找它。

You can get a list of commits whose changes are present in the release branch but not on master – and are therefore candidates for cherry picking – by using git log --cherry-pick and the triple-dot syntax : 您可以通过使用git log --cherry-pick三点语法获得一个提交列表,其中的更改存在于release分支中但不存在master - 因此是樱桃选择的候选者:

git log --cherry-pick --right-only master...release

Let's break it down: 让我们分解一下:

  • master...release selects the commits that are reachable from release but not master and vice versa. master...release选择可从release而不是master的提交,反之亦然。
  • --right-only shows only the commits reachable from the right side of the range, in this case the release branch --right-only显示从范围右侧可到达的提交,在本例中为release分支
  • --cherry-pick hides the commits from release whose changes have already been applied to master – ie they're considered patch equivalent . --cherry-pick隐藏了release的提交,其更改已经应用于master - 即它们被认为是补丁等效的

The key part here is --cherry-pick because that's what causes Git to determine whether a commit has been applied to a branch based on the commit's patch and not its SHA-1 hash. 这里的关键部分是--cherry-pick因为这是导致Git根据提交的补丁而不是SHA-1哈希来确定是否已将提交应用于分支的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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