使用git-svn:Pull,Merge或Rebase? [英] Using git-svn: Pull, Merge or Rebase?

查看:117
本文介绍了使用git-svn:Pull,Merge或Rebase?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为学习曲线的一部分,我一直在与git / git-svn学习曲线作斗争,昨天晚上,我做了一件非常非常糟糕的事情。我已经得到它纠正,但我希望能够理解我的方式错误。

我有一个svn存储库,我从中克隆了树干和分支(标签我忽略,因为我们没有在这些工作)。使用git,我创建了当前需要使用的每个分支的本地分支:



pre $ git checkout -b trunk svn / trunk
$ git checkout -b feature1 svn / branches / development / feature1
$ git checkout -b maint svn / branches / maintenance / previous-version

我让feature1成为我的活动分支,并在进行了几天抽离之前做了一些更改。昨天我想回到它想要集成对主干进行的任何更改,以便我正在使用最新最好的。我所做的是首先通过 git svn rebase 完成所有分支的更新(没有其他人在feature1分支上工作过)。在我的svn仓库中,所有的东西都是最新的,我试图重新分配。



以feature1作为我的活动分支,我做了一个git rebase trunk,认为我会将变化从trunk 拖入 feature1分支中。原来我非常非常错误。合并所有冲突后,我做了一个 git svn dcommit ,并发现我的更改已应用于中继。



我的第一个问题我的思维过程中的核心错误究竟在哪里?我的第二点是,经过大量阅读和谷歌搜索,我看到人们支持拉,合并和重新分配。考虑到我想将在一个本地分支中应用的更改合并到另一个本地分支,我应该做什么?这种情况下的最佳做法是什么?



感谢您的帮助。

你碰到的问题是rebase的命令行语法与你的(非常合理的,IMO)期望不符。

  $ git checkout feature1 
$ git rebase trunk

此序列将未共享的feature1提交添加到trunk的头部,并且您期望它将新的trunk提交放置到feature1的头部。
当你知道如何实现Git的数据模型时(这无疑是它的原因),语法实际上是有道理的。但对我来说,这与我所期望的功能相反。最好把它当作一个任意的构造来学习,而不是试图去达到期望。


你是对的,你明白如何使用git-svn与SVN回购交互。因此,忽略你在推拉和合并时发现的东西 - 在git和svn中,推拉和合并的行为好像有很多近乎正确的讨论。几乎是正确的仍然是错误的。


I've been fighting the git/git-svn learning curve and last night, as part of that learning curve, I did something very, very bad. I've since gotten it corrected, but I'm hoping to understand the error my ways.

I have an svn repository from which I've cloned the trunk and branches (tags I ignored since we don't work on those). Using git, I created local branches for each of the branches that I currently need to work with:

$ git checkout -b trunk svn/trunk
$ git checkout -b feature1 svn/branches/development/feature1
$ git checkout -b maint svn/branches/maintenance/previous-version

I made feature1 my active branch and made a few changes before getting pulled away for a few days. I cam back to it yesterday wanted to integrate any changes that had been made to the trunk so that I was working with the latest and greatest. What I did was a complete update of all brances first, via git svn rebase (no one else had worked on the feature1 branch). With everything up to date from my svn repository, I tried to rebase.

With feature1 as my active branch, I did a "git rebase trunk" thinking that I would be pulling changes from the trunk into the feature1 branch. Turns out I was very, very wrong. After merging all of the conflicts, I did a git svn dcommit and found that my changes had been applied to the trunk.

My first question is simply where was the core error in my thought process? My second is, after much reading and Googling, I see people espousing pulls, merges and rebases. Given the fact that I want to merge the changes applied in one local branch to another local branch, what should I have done? What's the best practice for this scenario?

Thanks for your help.

解决方案

The problem you ran into is that the command line syntax for rebase doesn't match your (very reasonable, IMO) expectations.

$ git checkout feature1
$ git rebase trunk

This sequence adds the unshared feature1 commits onto the HEAD of trunk, and you were expecting that it would place the new trunk commits onto the HEAD of feature1. The syntax actually makes some sense when you know how Git's data model is implemented (which is undoubtedly why it is the way it is). But to me it is the opposite of what I expect, functionally. It's best to learn it as an arbitrary construct and not try to have expectations.

You're right that you understand how to interact with the SVN repo using git-svn. So ignore what you found in Googling about push and pull and merge -- there's a lot of nearly right discussion by people who act as if push and pull and merge are the same in git and svn. Nearly right is still wrong.

这篇关于使用git-svn:Pull,Merge或Rebase?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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