你如何改变当前分支的变化,除了合并的变化之外? [英] How do you rebase the current branch's changes on top of changes being merged in?

查看:1102
本文介绍了你如何改变当前分支的变化,除了合并的变化之外?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好。如果我在分支上(比如 working ),并且我想合并来自另一个分支的更改(比如 master ),然后在工作分支上运行命令 git-merge master ,并且更改合并根本没有重新发布历史。如果我运行 git-rebase master ,那么 master 中的更改将重新设置为放在我的工作分支。但是如果我想合并来自 master 的更改,但是将工作中的更改重新设置为最高?我怎么做?可以这样做吗?



我可以在我的 master上运行 git-rebase working / code>分支将我的更改置于 master 分支的顶部,但我希望能够在工作分支,我不知道如何。我能想到的最接近的做法是从 master 创建一个新分支,然后在上面重新分配工作的更改那么,我会有一个新的分支,而不是改变工作分支。

解决方案

你已经得到了 rebase 的后退。 git rebase master 做你要求的 - 在当前分支上进行更改(因为它与主分离),并在 master ,然后将当前分支的头部设置为新历史记录的头部。它不会重播来自当前分支顶部的 master 的更改。


Okay. If I'm on a branch (say working), and I want to merge in the changes from another branch (say master), then I run the command git-merge master while on the working branch, and the changes get merged in without rebasing the history at all. If I run git-rebase master, then the changes in master are rebased to be put on the top of my working branch. But what if I want to merge in the changes from master but rebase my changes in working to be on top? How do I do that? Can it be done?

I could run git-rebase working on my master branch to put my changes on top in the master branch, but I'd like to be able to do that in my working branch, and I have no idea how. The closest that I can think of doing is creating a new branch from master and then rebase working's changes on top of that, but then I'd have a new branch instead of altering the working branch.

解决方案

You've got what rebase does backwards. git rebase master does what you're asking for — takes the changes on the current branch (since its divergence from master) and replays them on top of master, then sets the head of the current branch to be the head of that new history. It doesn't replay the changes from master on top of the current branch.

这篇关于你如何改变当前分支的变化,除了合并的变化之外?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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