简体   繁体   English

如何使用git-svn将远程分支与trunk同步

[英]How to synchronise remote branches with trunk using git-svn

I'm using git-svn to work against svn repository. 我正在使用git-svn来对抗svn存储库。 The layout is standard, and I have created the local repository with: 布局是标准的,我已经创建了本地存储库:

$ git svn clone -s http://mysvnrepo
(master)$ 

I need to work on a remote (svn) branch - MyBranch, so I created a local branch to track the remote one: 我需要在远程(svn)分支 - MyBranch上工作,所以我创建了一个本地分支来跟踪远程分支:

(master)$ git checkout -b localMyBranch remotes/MyBranch
(localMyBranch)$

I keep working and committing to the local branch as I go, and occasionally I do dcommit: 我继续工作并且在我去的时候去当地的分公司工作,偶尔我会这样做:

(localMyBranch)$ git svn dcommit

Meanwhile other people are working on the trunk, and from time to time I want to merge back the changes from trunk to my branch to keep them in sync. 与此同时,其他人正在使用主干,并且我不时会将更改从主干合并到我的分支以保持同步。 That's where I get really confused, as I could not find a good information how to perform this. 这就是我真的很困惑的地方,因为我找不到如何执行此操作的良好信息。 So far I know that I need to do: 到目前为止,我知道我需要这样做:

(localMyBranch)$ git svn dcommit
(localMyBranch)$ git checkout master
(master)$ git svn rebase

Now what? 怎么办? I read that this is NOT the right way to go: 我读到这不是正确的方法:

(master)$ git checkout localMyBranch
(localMyBranch)$ git rebase master

As it's going to mess the merge info for svn. 因为它会破坏svn的合并信息。

So what is the best way to "rebase" my remote svn branch to the remote trunk, preserving the merge info for svn? 那么将我的远程svn分支“重新绑定”到远程主干的最佳方法是什么,保留svn的合并信息?

You'll want to create a local working branch to handle your merge. 您将需要创建一个本地工作分支来处理您的合并。 The key is that you need a branch that is not actively tracking a remote svn branch. 关键是你需要一个没有主动跟踪远程svn分支的分支。

Try this: 尝试这个:

(localMyBranch)$ git checkout -b merge_work
(merge_work)$ git merge master
(merge_work)$ git checkout localMyBranch
(localMyBranch)$ git rebase merge_work

and vice-versa for merges the other way. 反之亦然,以另一种方式合并。

EDIT 编辑

If you are using git-svn 1.7.7 or higher, there is a configuration setting to tell git-svn to populate the mergeinfo property on the remote repository: 如果您使用的是git-svn 1.7.7或更高版本,则有一个配置设置可以告诉git-svn填充远程存储库上的mergeinfo属性:

git config --global svn.pushmergeinfo true

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

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