git与任意基本版本(git-svn)合并 [英] git merge against an arbitrary base revision (git-svn)
问题描述
我正在使用git-svn离线开发我公司的Subversion存储库,这是该项目的记录存储库。要启用管理可见性,我需要在SVN中维护我的功能分支。有时我需要在分支的整个生命周期中将我们的主干上的更改合并到功能分支中多次。由于我需要将分支保持在SVN中,所以我必须合并;一旦将它们推送到SVN,我就无法重新提交提交。此外, git svn dcommit
从合并提交中删除第二个父代。这意味着在第一个 git merge
之后的合并将分支根标识为合并基础,而不是最近的合并父项。因此,它尝试重新合并已经合并的更改,这几乎可以保证讨厌的冲突。
当我在SVN中合并时,手动指定基本修订:
svn merge -r 49262:49608 $ svn / trunk
有没有办法在git中进行手动指定的基本版本的合并?
更新:
请注意,我需要指定两个版本,包括基本版本和父版本。我有一个历史像
trunk:A - B - C - D - H - I
\\
功能:E - F - G - J - K
git svn dcommit
删除了 G
和 D
。我需要在
K
的基础上运行 I
到 D
。只需运行
$ git checkout feature
$ git merge trunk
会尝试合并 I
到 K
的基数 B
而不是 D
,它重新应用 C
和 D
导致极端合并冲突。使用SVN,我会运行一个命令,比如:
$ svn switch $ svn / feature
$ svn merge -r D: I $ svn / trunk
但 git merge
没有指定基本修订 D
的选项。我正在寻找类似于
$ git merge --base D trunk
但这样的选项似乎不存在。
解决方案(编辑:对于这样做的更低层次的方式,请参阅以前的修订版本,尽管这是最快的方式)
在正确的合并基础上使用
特性
的树进行nonce提交
git checkout`git commit-tree -p $ D -m - 特性^ {tree}`
合并中继到那里像往常一样
git merge trunk --no-commit
git commit#the两步执行器获取提交消息到已知位置
提交合并树作为新的
特性
小费git commit-tree -p特性-p trunk -F。 git / COMMIT_EDITMSG HEAD ^ {tree} \
| xargs git checkout -B功能
I'm using git-svn for offline development against my company's Subversion repository, which is the project's repository of record. To enable management visibility I'm required to maintain my feature branches in SVN. Sometimes I need to merge changes from our trunk to a feature branch multiple times over the lifetime of the branch. Since I'm required to keep the branch up-to-date in SVN I have to merge; I can't rebase commits once they're pushed to SVN. Further,
git svn dcommit
removes the second parent from merge commits. That means on merges after the firstgit merge
identifies the branch root as the merge base instead of the most recent merge parent. It therefore tries to re-merge changes that have already been merged, which pretty much guarantees nasty conflicts.When I merge in SVN I manually specify the base revision:
svn merge -r 49262:49608 $svn/trunk
Is there a way in git to do a merge with a manually specified base revision like that?
Update:
Note that I need to specify two revisions, both the base and the parent revision. I have a history like
trunk: A -- B -- C -- D -- H -- I \ \ feature: E -- F -- G -- J -- K
but
git svn dcommit
has removed the parent relationship betweenG
andD
. I need to run a merge ofI
on toK
with a base ofD
. Simply running$ git checkout feature $ git merge trunk
will try to merge
I
on toK
with a base ofB
instead ofD
, which re-appliesC
andD
resulting in extreme merge conflicts. With SVN I would run a command like$ svn switch $svn/feature $ svn merge -r D:I $svn/trunk
but
git merge
does not have an option to specify the base revisionD
. I'm looking for something like$ git merge --base D trunk
but such an option doesn't appear to exist.
解决方案(edit: for a lower-level way of doing this see previous revisions, this way's fastest though)
make a nonce commit with
feature
's tree parented on the correct merge basegit checkout `git commit-tree -p $D -m - feature^{tree}`
merge trunk into that as usual
git merge trunk --no-commit git commit # the two-stepper gets the commit message someplace known
commit the merged tree as the new
feature
tipgit commit-tree -p feature -p trunk -F .git/COMMIT_EDITMSG HEAD^{tree} \ | xargs git checkout -B feature
这篇关于git与任意基本版本(git-svn)合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!