合并后的Git rebase [英] Git rebase after merge

查看:158
本文介绍了合并后的Git rebase的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这已经被问了很多,但我还没有真正看到一个好的答案。这是我正在寻找的。

I know this has been asked a lot, but I have not really seen a good answer. Here is what I am looking for.

我们通过存储
我们希望历史记录显示每个功能的一次提交(存储合并到主服务器,所以有一个合并,一个提交)。
工作在功能分支中完成,并且经常发生提交。
Git rebase master用于重写历史记录以获得一次提交。

We do pull-requests in Stash.
We want the history to show one commit per feature (stash merges into master, so there is one merge, one commit). Work is done in feature branches, and commits happen often. Git rebase master is used to rewrite the history to get one commit.

我遇到的问题是,当几个功能进入master时,我会git合并我的功能分支与主,并添加几个提交。当我的代码准备好审查时,我将重新分配,现在git认为存在冲突。

The issue I am facing is that when a few features go into master, I git merge my feature branch with master, and add a few more commits. When my code is ready for review I rebase and now git thinks there are conflicts.

我想让历史看起来像是一样

What I want the history to really look like is the same as doing

$ git diff master > feature.patch
$ git checkout master
$ patch -p1 < feature.patch
$ git commit -am "[Bug-1234] Desc"

是有没有办法用rebase做到这一点?基本上接受所有,因为他们在HEAD。

Is there any way to do this with rebase? Basically accept all as they are in HEAD.

编辑:

下面是命令,让我在这现货

Here are the commands that put me in this spot

(feature/awesome) $ git merge master #resolve conflicts
(feature/awesome) $ git rebase --interactive master


推荐答案

$ c> rebase master 的情况是,自从master和你的特性分支的合并库被重播并且其中一些与已经被应用的压扁的提交冲突后,所有提交。

What happens in the default rebase master case is that all commits since the merge-base of master and your feature branch get replayed and some of those conflict with the squashed commits that have already been applied.

但是,如果您知道从功能分支合并到master的最后一个提交,那么您只能在feature_branch上应用LASTCOMMIT之后的提交。

However if you know the last commit that was merged from your feature branch into master, then you can apply only the commits after LASTCOMMIT on your feature_branch.

git rebase --onto=master LASTCOMMIT feature_branch

这篇关于合并后的Git rebase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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