git merge vs rebase 使用 git svn
我很困惑,我读了很多帖子、博客和文章,但不知道该去哪里。我正在使用一个 svn 服务器存储库,我用 git svn 拉取它并进行处理。我是目前唯一开发此功能的人(即没有上游更改)。
所以我有一个本地 git 主题分支 vacation
,我需要将其合并回 master 中以进行 dcommit,但我不想将所有提交压缩为一个大分支。
我尝试执行 git rebase -i master
,它删除了我 90% 的更改。
我应该做一个
git checkout master
git rebase vacation
git svn docmmit
还是a
git checkout vacation
git rebase master
git checkout master
git merge vacation --ff-only
git svn docmmit?
我害怕这样b/c我之前尝试时发生了什么 有人可以简要解释一下我应该做什么以及为什么我必须这样做吗?
I am very confused, I have read several posts, blogs and articles and don't know where to go. I am using an svn server repo that I pull down with git svn and work on. I am currently the only person developing this ( i.e. no upstream changes ) .
So i have a local git topic branch vacation
, which i need to merge back into master to dcommit, but i don't want to squash all the commits into one big one.
I tried to do a git rebase -i master
and it erased 90% of my changes.
do i do a
git checkout master
git rebase vacation
git svn docmmit
Or a
git checkout vacation
git rebase master
git checkout master
git merge vacation --ff-only
git svn docmmit?
I am afraid of that way b/c what happened when i tried before
can someone please briefly explain what I should do and why I have to do it that way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
所以我想我明白了。
我没有对上游进行任何更改,但这正是我想要的。
so I think i figured it out.
I had no upstream changes, but this was exactly what i wanted.
你应该合并或挑选到master而不是rebase。
至于为什么,这是一个排序的问题。 Rebase 意味着您想要更改历史记录,以使您的主题分支出现在历史记录中的 master 之前。如果您合并或挑选提交,那么它会将您的提交添加到 master 之上。
因此,一个完整的周期就像是
为了更全面地解释 rebase,我个人设置中的一个示例:除了 master 之外,我还维护一个本地分支工作,我将其用作项目本地配置的基础。它有一些我不想提交的自定义属性文件之类的东西。我需要使其与 master 分支保持同步,因此我从 master 开始执行此操作:
现在 git 重建工作分支的历史记录,将所有本地配置提交放置在堆栈的头部。它几乎是在主分支上重新创建分支。如果我要发布
而不是重新设置基准,那么对于跛脚的人来说,结果将是相同的,但历史确实会非常不同。这两个历史记录将得到解决,可能会导致合并提交,而不是一个基于另一个历史记录。
You should merge or cherry-pick into master not rebase.
As for why, its a question of ordering. Rebase implies you want to alter the history to make your topic branch appear before master in the history. If you merge or cherry-pick commits then it will add your commits on top of master.
So a complete cycle would be something like
To explain rebase more fully an example from my personal setup: In addition to master I also maintain a local branch work which I use as the base for my local configuration of out project. It has things like custom property files which I don't ever want to commit. I need to keep this in sync with the master branch so I do this starting from master:
Now git reconstructs the history of the work branch placing all the local config commits at the head of the stack. It litterally REcreates the branch BASEd on the master branch. If I were to issue
instead of rebasing then the result to the lamen eye would be the same but the history would be very different indeed. The two histories would be resolved, possibly resulting in merge commits, instead of one based on top of the other.