简体   繁体   English

使用git-svn在svn中轻松合并

[英]Easy merging in svn using git-svn

At work we are using a lot of branches in SVN and there are problems in merging. 在工作中,我们在SVN中使用了很多分支,并且在合并方面存在问题。 I heard that a good idea is to use git better merging with git-svn. 我听说一个好主意是使用git更好地与git-svn合并。 I try to play with it using msysgit, however its not as easy as it seems. 我尝试使用msysgit来玩它,但它并不像看起来那么容易。

I know I can checkout the whole project using git svn clone -s , however it does not see branches(as normal git branches). 我知道我可以使用git svn clone -s检查整个项目,但是它没有看到分支(正常的git分支)。 I find git-svn very hard to use compare to git or svn. 我发现git-svn与git或svn相比很难使用。

Could you describe in steps how to do that kind of merging? 你能用步骤描述如何进行这种合并吗?

git-svn will gives you a branches for each branches and tag in SVN (unless you use a ruby script like svn2git ) git-svn将为SVN中的每个分支和标记提供一个分支(除非你使用像svn2git这样ruby脚本

The idea is to always git-svn rebase / git-svn dcommit a SVN branch. 我的想法是始终git-svn rebase / git-svn dcommit一个SVN分支。
ie, you will synchronize a Git branch with a SVN one ( git-svn rebase ), and you will update an SVN branch from the new commits in the corresponding Git branch ( git-svn dcommit ). 即,您将Git分支与SVN分支同步( git-svn rebase ),您将从相应Git分支( git-svn dcommit )中的新提交更新SVN分支。

Any local Git branches, with all their fancy merges, must be local (ie all those branches/merges in Git won't have any equivalent in the SVN repo) 任何本地Git分支,其所有花哨的合并,必须是本地的 (即Git中的所有分支/合并在SVN回购中不具有任何等价物)

As the caveat in the git-svn goes (see the SO question " git-svn merge 2 svn branches "): 正如git-svn的警告所述(参见SO问题“ git-svn merge 2 svn branches ”):

For the sake of simplicity and interoperating with a less-capable system (SVN), it is recommended that all git svn users clone , fetch and dcommit directly from the SVN server, and avoid all git clone / pull / merge / push operations between git repositories and branches. 为了简单和与功能较弱的系统(SVN)互操作,建议所有git svn用户直接从SVN服务器clonefetchdcommit ,并避免git之间的所有git clone / pull / merge / push操作存储库和分支机构。
The recommended method of exchanging code between git branches and users is git format-patch and git am , or just ' dcommit 'ing to the SVN repository. 在git分支和用户之间交换代码的推荐方法是git format-patchgit am ,或者只是' dcommit '到SVN存储库。

Running git merge or git pull is NOT recommended on a branch you plan to dcommit from. 运行git mergegit pull不建议您计划一个分支dcommit从。
Subversion does not represent merges in any reasonable or useful fashion; Subversion不以任何合理或有用的方式表示合并; so users using Subversion cannot see any merges you've made. 因此使用Subversion的用户无法看到您所做的任何合并。 Furthermore, if you merge or pull from a git branch that is a mirror of an SVN branch, dcommit may commit to the wrong branch. 此外,如果您从作为SVN分支镜像的git分支合并或拉出,则dcommit可能会提交到错误的分支。

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

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