通过 GIT 使用(不同的)SVN 远程存储库的正确方法是什么
环境:
- 一个名为 svn+ssh://yourserver/svn/prj 的附近
- SVN 存储库 一个名为 svn+ssh://theirserver/svn/prj 的外部
- SVN 存储库 一个名为“myrep”的本地 git 存储库,它是一个 git-svn附近的克隆
- 使用:
git svn clone -R附近svn -s svn+ssh://yourserver/svn/prj
所以有一个主干和一些分支(都是从主干r3分叉/复制的。< /里>
- 使用:
$ git branch -a * master remotes/b1 remotes/b2 remotes/trunk
我们来了。
在我的 master(这是来自远程/主干的分支)中进行的简单更改被添加,然后提交,然后通过 git svn dcommit“推送”到 SVN
。远的。 树现在看起来像这样:
$ git log --graph --oneline --all * 1e6277f change 3 in b2 * 7623755 two new branches | * 7901fad change3 in b1 | * e83f135 two new branches |/ | * 6fac7ad change 3 | * 5858495 new file test3 | * 4cdf2ed change2 | * 511ed7a change1 |/ * d5c68ab init
结论 1:
git svn dcommit
将本地 master 分支中所做的所有更改发送到远程/主干 SVN,然后对其进行变基 输出和树如下所示:
$ git add test $ git ci [master 8a03901] modified test via git for SVN trunk 1 files changed, 1 insertions(+), 1 deletions(-) $ git svn dcommit Committing to svn+ssh://yourserver/svn/prj/trunk ... M test Committed r9 M test r9 = 542eb78f841fc1a4d12f4a72f68e40e3069f3309 (refs/remotes/trunk) No changes between current HEAD and refs/remotes/trunk Resetting to the latest refs/remotes/trunk $ git log --graph --oneline --all * 542eb78 modified test via git for SVN trunk * 6fac7ad change 3 * 5858495 new file test3 * 4cdf2ed change2 * 511ed7a change1 | * 1e6277f change 3 in b2 | * 7623755 two new branches |/ | * 7901fad change3 in b1 | * e83f135 two new branches |/ * d5c68ab init
问题 1:
- 为什么 init 是 b1 和 b2 的父级?
- 为什么我的主人与“init”树相同,它不应该是远程树的“分支”吗?合并状态仍然是“未合并”,因为只完成了变基
问题2:
修补远程/b1某些更改的正确/最佳方法是什么
我的方式:使用git checkout -b myb1创建本地分支myb1 Remotes/b1
然后 $ git diff master^..master | patch -p1
then add, ci, dcommit
问题 3:
如何获取有关我的分支所属/分叉的远程路径的信息?配置没有告诉我任何有关它的信息:
$ git config --get-regexp svn-remote svn-remote.nearbysvn.url svn+ssh://yourserver/svn/prj svn-remote.nearbysvn.fetch trunk:refs/remotes/trunk svn-remote.nearbysvn.branches branches/:refs/remotes/ svn-remote.nearbysvn.tags tags/:refs/remotes/tags/
问题4:
这有点棘手: 第二个(外部)SVN 现在是第一个 SVN 的“副本”,但有一个例外:外部也可能被其他人使用。 目前,在“附近”中所做的所有更改都必须在外部更改中再次完成(修补第二个工作副本中的文件,依此类推...
如果此删除 SVN 现在是第二个远程 SVN 存储库,那么最佳实践是什么“通过 git 合并优化”?
是的,有一些很棒的人会使用 BeyondCompare 等(参见 如何比较 Git 存储库中的源代码与 SVN 存储库中的源代码)。但这不是我最喜欢的“合并”方式,
我建议我需要: * 本地分支,如 myb1、master、master2 * 为我的工作创建分支/分支,例如 master-taskX (git checkout -b master-taskX
) * 然后我可以使用合并将我的更改返回到主版本,然后提交它们?
我很快就会很高兴收到一些 git-svn 专家的来信;)
谨致问候, ~Marcel
附录:
仅供参考:这是“附近”的初始 SVN 历史记录:
------------------------------------------------------------------------ r8 | konqi | 2011-01-19 17:48:51 +0100 (Mi, 19 Jan 2011) | 2 lines Changed paths: M /branches/b2/test3 change 3 in b2 ------------------------------------------------------------------------ r7 | konqi | 2011-01-19 17:48:42 +0100 (Mi, 19 Jan 2011) | 2 lines Changed paths: M /branches/b1/test3 change3 in b1 ------------------------------------------------------------------------ r6 | konqi | 2011-01-19 17:46:07 +0100 (Mi, 19 Jan 2011) | 2 lines Changed paths: M /trunk/test3 change 3 ------------------------------------------------------------------------ r5 | konqi | 2011-01-19 17:36:13 +0100 (Mi, 19 Jan 2011) | 3 lines Changed paths: A /branches/b1 (from /trunk:1) R /branches/b1/test (from /trunk/test:2) R /branches/b1/test2 (from /trunk/test2:3) A /branches/b1/test3 (from /trunk/test3:4) A /branches/b2 (from /trunk:1) R /branches/b2/test (from /trunk/test:2) R /branches/b2/test2 (from /trunk/test2:3) A /branches/b2/test3 (from /trunk/test3:4) two new branches ------------------------------------------------------------------------ r4 | konqi | 2011-01-19 17:30:05 +0100 (Mi, 19 Jan 2011) | 2 lines Changed paths: A /trunk/test3 new file test3 ------------------------------------------------------------------------ r3 | konqi | 2011-01-19 17:28:46 +0100 (Mi, 19 Jan 2011) | 2 lines Changed paths: M /trunk/test2 change2 ------------------------------------------------------------------------ r2 | konqi | 2011-01-19 17:28:34 +0100 (Mi, 19 Jan 2011) | 2 lines Changed paths: M /trunk/test change1 ------------------------------------------------------------------------ r1 | konqi | 2011-01-19 17:28:10 +0100 (Mi, 19 Jan 2011) | 2 lines Changed paths: A /branches A /tags A /trunk A /trunk/test A /trunk/test2 init ------------------------------------------------------------------------
The environnement:
- A nearby SVN Repository called svn+ssh://yourserver/svn/prj
- An external SVN Repository called svn+ssh://theirserver/svn/prj
- A local git repository that called "myrep" which is a git-svn clone of the nearby one
- made with:
git svn clone -R nearbysvn -s svn+ssh://yourserver/svn/prj
so there is a trunk and some branches (both forked / copied from trunk r3.
- made with:
$ git branch -a * master remotes/b1 remotes/b2 remotes/trunk
Here we come.
Simple changes made in my master (which is a branch from the remotes/trunk) are added, then committed, then "pushed" to the SVN via git svn dcommit
.
So good, so far.
The tree now looks like this:
$ git log --graph --oneline --all * 1e6277f change 3 in b2 * 7623755 two new branches | * 7901fad change3 in b1 | * e83f135 two new branches |/ | * 6fac7ad change 3 | * 5858495 new file test3 | * 4cdf2ed change2 | * 511ed7a change1 |/ * d5c68ab init
Conclusion 1:
git svn dcommit
sends all changes made in my local master branch to the remotes/trunk SVN, then rebase it
The output and tree looks like this:
$ git add test $ git ci [master 8a03901] modified test via git for SVN trunk 1 files changed, 1 insertions(+), 1 deletions(-) $ git svn dcommit Committing to svn+ssh://yourserver/svn/prj/trunk ... M test Committed r9 M test r9 = 542eb78f841fc1a4d12f4a72f68e40e3069f3309 (refs/remotes/trunk) No changes between current HEAD and refs/remotes/trunk Resetting to the latest refs/remotes/trunk $ git log --graph --oneline --all * 542eb78 modified test via git for SVN trunk * 6fac7ad change 3 * 5858495 new file test3 * 4cdf2ed change2 * 511ed7a change1 | * 1e6277f change 3 in b2 | * 7623755 two new branches |/ | * 7901fad change3 in b1 | * e83f135 two new branches |/ * d5c68ab init
Question 1:
- why is init the parent for b1 and b2?
- why is my master the same as the "init" tree, shouldn't it be a "branch" from the remote one? The merge status is still "unmerged" cause only a rebase was done
Question 2:
what is the correct / best way to patch some changes to the remote/b1
my way: create a local branch myb1 with git checkout -b myb1 remotes/b1
then $ git diff master^..master | patch -p1
then add, ci, dcommit
Question 3:
how can I get informations about my branches to which remote paths they belong to / are forked from? config doesn't tell me anything about it:
$ git config --get-regexp svn-remote svn-remote.nearbysvn.url svn+ssh://yourserver/svn/prj svn-remote.nearbysvn.fetch trunk:refs/remotes/trunk svn-remote.nearbysvn.branches branches/:refs/remotes/ svn-remote.nearbysvn.tags tags/:refs/remotes/tags/
Question 4:
This is some more tricky:
The second (external) SVN is now a "duplicate" of the first one, with one exception: external might be used by others too.
Currently all changes made in "nearby" has to be done again in the external one (patching files in a second working copy, and so on...
If this remove SVN is now a second remote SVN repository, what is best practice to "optimize" this with merges via git?
Yes, there are some great guy'S who will use BeyondCompare, etc (see How to compare source in Git repository between source in SVN repository). But this is NOT my favorite way to "merge"
I propose I need:
* local branches like myb1, master, master2
* forks / branches of this for my work like master-taskX (git checkout -b master-taskX
)
* then I might use merge to get my changes back to master and then dcommit them??
I'll be glad to hear from some git-svn experts soon ;)
With kind regards,
~Marcel
Appendix:
FYI: here is the inital SVN history for "nearby":
------------------------------------------------------------------------ r8 | konqi | 2011-01-19 17:48:51 +0100 (Mi, 19 Jan 2011) | 2 lines Changed paths: M /branches/b2/test3 change 3 in b2 ------------------------------------------------------------------------ r7 | konqi | 2011-01-19 17:48:42 +0100 (Mi, 19 Jan 2011) | 2 lines Changed paths: M /branches/b1/test3 change3 in b1 ------------------------------------------------------------------------ r6 | konqi | 2011-01-19 17:46:07 +0100 (Mi, 19 Jan 2011) | 2 lines Changed paths: M /trunk/test3 change 3 ------------------------------------------------------------------------ r5 | konqi | 2011-01-19 17:36:13 +0100 (Mi, 19 Jan 2011) | 3 lines Changed paths: A /branches/b1 (from /trunk:1) R /branches/b1/test (from /trunk/test:2) R /branches/b1/test2 (from /trunk/test2:3) A /branches/b1/test3 (from /trunk/test3:4) A /branches/b2 (from /trunk:1) R /branches/b2/test (from /trunk/test:2) R /branches/b2/test2 (from /trunk/test2:3) A /branches/b2/test3 (from /trunk/test3:4) two new branches ------------------------------------------------------------------------ r4 | konqi | 2011-01-19 17:30:05 +0100 (Mi, 19 Jan 2011) | 2 lines Changed paths: A /trunk/test3 new file test3 ------------------------------------------------------------------------ r3 | konqi | 2011-01-19 17:28:46 +0100 (Mi, 19 Jan 2011) | 2 lines Changed paths: M /trunk/test2 change2 ------------------------------------------------------------------------ r2 | konqi | 2011-01-19 17:28:34 +0100 (Mi, 19 Jan 2011) | 2 lines Changed paths: M /trunk/test change1 ------------------------------------------------------------------------ r1 | konqi | 2011-01-19 17:28:10 +0100 (Mi, 19 Jan 2011) | 2 lines Changed paths: A /branches A /tags A /trunk A /trunk/test A /trunk/test2 init ------------------------------------------------------------------------
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题 2:
问题3:
问题 4:
这有点棘手:第二个(外部)SVN 现在是第一个 SVN 的“重复”,但有一个例外:外部也可能被其他人使用。目前,在“附近”中所做的所有更改都必须在外部更改中再次完成(在第二个工作副本中修补文件,等等......
如果此删除 SVN 现在是第二个远程 SVN 存储库,那么通过 git 合并来“优化”此存储库的最佳实践是什么?
是的,有一些很棒的人会使用 BeyondCompare 等(请参阅如何在 SVN 存储库中的源之间比较 Git 存储库中的源)。但这不是我最喜欢的“合并”方式
我建议我需要: * 本地分支,如 myb1、master、master2 * 为我的工作分叉/分支,如 master-taskX (git checkout -b master-taskX) * 然后我可能会使用合并来取回我的更改掌握然后提交它们?
请注意,根据我的经验,git merge 与 git-svn 配合得不好,因此您可能希望坚持使用上述技术,这些技术不会在 git 历史记录中创建双父提交。
Question 2:
Question 3:
Question 4:
This is some more tricky: The second (external) SVN is now a "duplicate" of the first one, with one exception: external might be used by others too. Currently all changes made in "nearby" has to be done again in the external one (patching files in a second working copy, and so on...
If this remove SVN is now a second remote SVN repository, what is best practice to "optimize" this with merges via git?
Yes, there are some great guy'S who will use BeyondCompare, etc (see How to compare source in Git repository between source in SVN repository). But this is NOT my favorite way to "merge"
I propose I need: * local branches like myb1, master, master2 * forks / branches of this for my work like master-taskX (git checkout -b master-taskX) * then I might use merge to get my changes back to master and then dcommit them??
git checkout -b temp A/master; git rebase --onto trunk HEAD^; git svn dcommit; git checkout master; git branch -D temp
to commit the changes to repo B. To dcommit multiple revs you will neat to adjust the number of carats in the rebase command.Note generally that in my experience git merge doesn't play well with git-svn, so you probably want to stick to techniques like the above which do not create two-parent commits in the git history.
我会为 2 个 svn 存储库创建 2 个单独的 git 存储库。然后,通过变基等方式在 Git 存储库之一中协调更改。
I would make 2 separate git repos for the 2 svn repos. Then, coordinate changes via rebasing, etc. in one of the Git repositories.