如何使用原子git-svn dcommit操作保留本地分支历史记录? [英] How to keep local branch history with an atomic git-svn dcommit operation?

查看:172
本文介绍了如何使用原子git-svn dcommit操作保留本地分支历史记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在git分支中开发各种功能.当我想通过git-svn将代码检入SVN时,请执行以下操作:

git co feature_branch
git svn rebase
git co master
git svn rebase
git merge --no-ff feature_branch
git commit --amend
git svn dcommit

这相当合理,除非在此过程中任何时候任何开发人员都承诺使用SVN,在这种情况下,要么:

  • 如果在我对feature_branch和master重新设置基准的时间之间进行了SVN提交,则会得到一条类似于以下内容的日志:

*   4e6992a BUG-003 My SVN commit (containing cdb40ba and 3b18ea4)
|\
| * cdb40ba local commit 1
| * 3b18ea4 local commit 2
* | cf8a028 BUG-002 Another developer's SVN commit
|/
* 940c613 BUG-001 Another developer's SVN commit

  • 如果在重新设置主服务器和svn dcommit的时间之间进行了SVN提交,则由于合并问题,后者会失败(在这种情况下,我会进行硬重置并重新开始)

如何在单个原子操作中完成此操作?

解决方案

我认为,由于SVN的工作方式,这个问题无法用git-svn解决(每个修订版本创建都是一个单独的事务,但是您可以创建一个事务会创建多个修订版).也许您可以使用SVN锁解决它,但是这种方法有其缺点.

Pure Git可以根据需要将所有的历史记录作为一个原子操作推到一起.如果可以访问SVN信息库,则可以将SubGit安装到其中,并使用它将为SVN信息库创建的Git接口(纯Git接口,而不是git-svn).

I do my development of various features in git branches. When I want to check my code into SVN via git-svn, I do the following:

git co feature_branch
git svn rebase
git co master
git svn rebase
git merge --no-ff feature_branch
git commit --amend
git svn dcommit

This works reasonably well, unless another developer commits to SVN any time during this process, in which case either:

  • If a SVN commit is made between the time I rebase feature_branch and master, I get a log that looks like the following:

*   4e6992a BUG-003 My SVN commit (containing cdb40ba and 3b18ea4)
|\
| * cdb40ba local commit 1
| * 3b18ea4 local commit 2
* | cf8a028 BUG-002 Another developer's SVN commit
|/
* 940c613 BUG-001 Another developer's SVN commit

  • If a SVN commit is made between the time I rebase master and svn dcommit, the latter fails due to merge issues (in which case I do a hard reset and start over)

How can I accomplish this in a single atomic operation?

解决方案

I think, this problem is not solvable with git-svn because of the way SVN works (each revision creation is a separate transaction, but you can create a transaction that creates several revisions). Maybe you could solve it using SVN locks, but this approach has its shortcomings.

Pure Git pushes all your the history together as an atomic operation as you need. If you have an access to your SVN repository, you can install SubGit into it and use Git interface (pure Git interface, not git-svn) that it will create for your SVN repository.

这篇关于如何使用原子git-svn dcommit操作保留本地分支历史记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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