【问题标题】:Get changes from feature branch 1 into branch 2 with Git rebase [closed]使用 Git rebase 将功能分支 1 更改为分支 2 [关闭]
【发布时间】:2023-03-27 10:10:02
【问题描述】:

我有 两个 功能分支 branch-1branch-2

我需要将功能 branch-1 更改为功能 branch-2

如何使用git rebase 执行此操作?下面是正确的吗?

git checkout branch-1

git rebase branch-2 branch-1

【问题讨论】:

  • 你到底在问什么?你已经回答了你的问题。这行得通吗?

标签: git rebase


【解决方案1】:

合并更改不是更好吗?

git checkout -b branch-1

git merge branch-2

如果你想使用变基,那么根据this link你可以使用以下命令变基:

git checkout -b branch-1

git rebase branch-2

【讨论】:

  • 所以在你上面的命令之后它会将branch-1放在branch-2之上?所以branch-1 的所有(后面)更改现在也在branch-2 中?
  • 命令之后,branch-1 将放在branch-2 之上。但是branch-2 的所有更改现在都在branch-1 中。不是反过来。你可以使用git log --graph查看哪个分支在哪里。
  • 好的,谢谢。但是branch-1 仍处于拉取请求中,在上述变基之后,我可以完成分支二,仍然可以推送branch-2 并为branch-2 创建拉取请求?
  • 有很多未知数,但在大多数情况下,我相信这是可能的,是的。
猜你喜欢
  • 2020-01-31
  • 2016-09-22
  • 2016-02-06
  • 2017-02-12
  • 2012-03-24
  • 2016-08-22
  • 2021-08-20
  • 1970-01-01
  • 2014-07-01
相关资源
最近更新 更多