git svn dcommit 无需变基
我们公司使用(并且支持!)SVN,但我倾向于使用 git。我想要尝试的是拥有 git 存储库 - 每个项目一个,项目开发人员将能够从这个存储库中提取(当然,如果他们愿意的话,也可以互相提取)。但我仍然想将所有更改推送到 SVN,因为 SVN 是由我们的技术支持维护的。
我正在使用以下存储库测试该场景:
- SVN-repository - 这是由我们公司维护的,我们的团队应该在某个时候将所有更改推送到那里
- git-svn-clone - 这是从上面的 SVN 克隆的 git 存储库 - 所有项目开发人员都应该将他们的提交推送到这里
- git-dev-clone - 这是开发人员的 git 存储库。
我注意到直接使用“git svn rebase”和“git svn dcommit”的唯一问题是,每次从开发人员的 git 存储库推送到 git-svn-clone 存储库后,一旦发生更改,我必须立即重新设置开发人员的存储库的基址将传播到 SVN 并重新建立基础。我想要实现的是避免每次推送后重新定位。
请注意,我假设每个项目开发人员都只会使用 git 存储库,而没有人会直接使用 SVN。
我能够在推送后通过在“git-svn-clone”存储库中一一检查每个 git 提交并使用 SVN 客户端将这些更改提交到 SVN 来手动实现此行为。我相信“git svn dcommit”会做同样的事情,但它也会从 SVN 同步回来并更改提交 SHA 标识符,这迫使我重新设置基准。
PS:git svn dcommit
的--no-rebase
选项没有帮助,因为第一次提交传播到SVN后git svn dcommit
没有帮助允许我对 SVN 进行更多更改,直到之前的更改重新建立。我已经尝试过这种行为一次,可能会忽略一些东西。
Our company uses (and supports!) SVN, but I tend to use git. What I want to try is to have git repository - one per project, project developers will be able to pull from this repository (and of course pull from each other if they will want to). But I still want to push all the changes to the SVN, because SVN is being maintained by our tech-support.
I was testing the scenario with following repositories:
- SVN-repository - this one is maintained by our company and our team should push all changes there at some point
- git-svn-clone - this is git repository cloned from SVN above - all project developers should push their commits here
- git-dev-clone - this is developer's git repository.
The only issue with straightforward usage of 'git svn rebase' and 'git svn dcommit' that I've noticed is that after each push from developer's git repository to the git-svn-clone repository I have to rebase developer's repository as soon as changes will be propagated to SVN and rebased. What I want to achieve is to avoid rebasing after each push.
Please note that I'm assuming that every project developer will use only git repository and nobody will use SVN directly.
I was able to achieve this behavior manually by checking out every git commit one by one in 'git-svn-clone' repository after push and committing those changes to the SVN using SVN client. I believe that 'git svn dcommit' does the same but it also syncs back from SVN and changes commit SHA identifiers which forces me to rebase.
P.S.: --no-rebase
option for git svn dcommit
didn't help since after first commit propagated to SVN git svn dcommit
didn't allow me committing more changes to the SVN until previous one was rebased. I've tried this behavior once and probably could overlook something.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
实际上比这更糟糕... dcommit 会更改上传到 SVN 的提交(添加 git-svn-id 行、更改作者信息等),即使您破解了 dcommit 以不尝试重新设置基准。
基本上,如果不进行变基,git-svn 就无法从 SVN 同步回来。正在开发一个新的 git<->SVN 界面,它可能会消除此限制,但尚未准备就绪。
恐怕如果您想与 SVN 存储库保持同步,那么如果现在不进行变基,您的方案将无法工作。
It's actually even worse than that... dcommit changes the commits uploaded to SVN (adding git-svn-id lines, changing the authorship information, etc.) even if you hacked dcommit to not try to rebase.
Basically, git-svn is not able to sync back from SVN ever without doing rebases. A new git<->SVN interface that might remove this limitation is being worked on, but it's not ready yet.
I'm afraid that if you want to keep in sync with the SVN repository, your scenario will not work without rebasing right now.
这个答案意味着使用
--no-metadata
将从提交消息中删除 svn 信息。 可能使 dcommit 使用相同的提交,但我尚未验证:您可能还需要
- -authors-file
确保 git 和 svn 用户名完全匹配。This answer implies that using
--no-metadata
will remove svn information from commit messages. That may make dcommit use the same commits, but I haven't verified:You may also need
--authors-file
to ensure git and svn user names are exact matches.