简体   繁体   English

“git rebase <branch> “关于git svn repo改变了远程跟踪目的地?

[英]“git rebase <branch>” on git svn repo changed remote tracking destination?

I have a git svn repo. 我有一个git svn repo。 I have multiple release branches in here. 我在这里有多个发布分支。 I was preparing a new release and as part of it, I figured I'd do a "git rebase" from the previous release to pull over any changes that hadn't been merged. 我正在准备一个新的版本,作为其中的一部分,我想我会从之前的版本中做一个“git rebase”来完成任何尚未合并的更改。

So I set up my branches... 所以我建立了我的分支......

git branch new_release remotes/svn-branches/new_release
git branch old_release remotes/svn-branches/old_release

And then I did the rebase... 然后我做了改变...

git checkout new_release
git rebase old_release
# watch it pull a bunch of commits
git svn dcommit
    Committing to https://svn.mysvn.net/repo/releases/old_release ...

After I did the "svn dcommit" I almost crapped my pants. 在我做了“svn dcommit”后,我差点把裤子弄坏了。 It was hosing my old release branch in Subversion! 它在Subversion中使用我的旧版本分支!

Why did the remote tracking branch change as a result of doing the rebase? 为什么远程跟踪分支因为进行rebase而改变?

How do I fix the situation I've gotten myself into? 我如何解决自己陷入困境的局面?

EDIT: Okay, for getting myself out I believe I can do the following: http://svnbook.red-bean.com/en/1.5/svn.branchmerge.basicmerging.html#svn.branchmerge.basicmerging.undo 编辑:好的,为了让自己离开,我相信我可以做到以下几点: http//svnbook.red-bean.com/en/1.5/svn.branchmerge.basicmerging.html#svn.branchmerge.basicmerging.undo

Since there are only a handful of commits that were on the new_release branch that were pulled to old_release, I can revert them by hand individually on the SVN repo. 由于new_release分支上只有少数提交被拉到old_release,我可以在SVN repo上单独手动还原它们。 I'm still confused at what happened here though. 我仍然对这里发生的事感到困惑。

EDITx2: Yep, here are some steps to verify. EDITx2:是的,这里有一些验证步骤。

  1. Set up two git branches tracking remotely to SVN branches 设置两个git分支,远程跟踪SVN分支
  2. Check out one of the branches 看看其中一个分支机构
  3. Run git svn info and observe the URL points to the correct location in SVN 运行git svn info并观察URL指向SVN中的正确位置
  4. Run git rebase <other_branch> 运行git rebase <other_branch>
  5. Run git svn info again and observe the URL changed to point to the other branch location in SVN 再次运行git svn info并观察更改的URL以指向SVN中的其他分支位置

Looks like you've made a common mistake while working with git-svn. 看起来你在使用git-svn时遇到了一个常见的错误。

There's no such thing as "tracking branches" in git-svn. 在git-svn中没有“跟踪分支”这样的东西。 It always determines URL of branch to dcommit to by first-parent history until the first commit with "git-svn-id:" signature is met. 它总是通过第一父历史确定分支的URL,直到满足第一次提交“git-svn-id:”签名为止。 The URL near this signature is the URL where the commit will be pushed. 此签名附近的URL是将推送提交的URL。 But note, there's a double check: the URL and revision near the signature is compared with data structures in .git/svn/refs directory and if the URL and revision contradicts them (that is true for rebased commits because rebase doesn't touch those structures), it is not considered. 但请注意,有一个双重检查:签名附近的URL和修订版与.git / svn / refs目录中的数据结构进行比较,如果URL和修订版与它们相矛盾(对于重新提交的提交也是如此,因为rebase不接触那些结构),没有考虑。 So the old branch URL was the first URL of commit that wasn't rebased. 所以旧的分支URL是第一个没有重新定位的提交URL。

If you want pure Git experience, you might try SubGit as git-svn replacement. 如果你想要纯粹的Git体验,你可以试试SubGit作为git-svn替换。 Since 2.0 it allows to create a writable pure Git mirror of your SVN repository, taking care about synchronization and concurrency. 从2.0开始,它允许创建SVN存储库的可写纯Git镜像,注意同步和并发。 Run

$ subgit configure --svn-url <SVNURL> project.git
$ #adjust projectX.git/subgit/{config,authors.txt,passwd} 
$ subgit install project.git
$ git clone project.git project/

After installation you may use it as a normal Git repository. 安装后,您可以将其用作普通的Git存储库。 So for you example you run: 所以对于你的例子你运行:

$ git checkout new_release
$ git rebase old_release
$ git push origin new_release

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

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