我有两个分支,电子邮件和分期。分期是最新的一个,我不再需要旧的更改在电子邮件分支,但我不想删除他们。

我只想将所有staging的内容转储到电子邮件中,以便它们都指向同一个提交。这可能吗?


当前回答

我已经看到了几个答案,这是唯一的程序,让我解决没有任何冲突。

如果你想要在branch_old中对branch_new的所有更改,那么:

git checkout branch_new
git merge -s ours branch_old
git checkout branch_old
git merge branch_new

一旦应用了这四个命令,您就可以毫无问题地推送branch_old了

其他回答

我想合并两个分支,以便old_branch中的所有内容都与new_branch中的内容更新

对我来说,这就像一个魔法:

$ git checkout new_branch
$ git merge -m 'merge message' -s ours origin/old_branch
$ git checkout old_branch
$ git merge new_branch
$ git push origin old_branch

如果你像我一样不想处理归并,你可以执行上面的步骤,除了使用强制而不是归并,因为它会创建一个分散注意力的日志记录:

git checkout email
git reset --hard staging
git push origin email --force

注意:除非你真的不想再在邮件里看到这些东西。

我已经看到了几个答案,这是唯一的程序,让我解决没有任何冲突。

如果你想要在branch_old中对branch_new的所有更改,那么:

git checkout branch_new
git merge -s ours branch_old
git checkout branch_old
git merge branch_new

一旦应用了这四个命令,您就可以毫无问题地推送branch_old了

如何:

git branch -D email
git checkout staging
git checkout -b email
git push origin email --force-with-lease
git checkout email
git merge -m "Making email same as staging disregarding any conflicts from email in the process" -s recursive -X theirs staging