简体   繁体   English

将更改从另一个分支应用于新的git分支

[英]Applying changes to a new git branch from another branch

In my git project I have two three branches: 在我的git项目中,我有两个三个分支:

  • develop
  • feature/one - cut from develop and has extensive changes to it; feature/one -从developdevelop并对其进行了广泛的更改; has not been merged back into develop yet 尚未合并回develop
  • feature/two - must be cut from develop as well, but must initially (when it gets cut) contain all the exact same changes to it as feature/one has (and additional changes will be added to this branch as well) feature/two -也必须develop删除,但必须在开始时(被剪切时)包含与feature/one完全相同的所有更改(并且其他更改也将添加到此分支中)

For reasons outside the scope/context of this question, it is not possible to cut feature/two from feature/one ! 由于此问题的范围/上下文之外的原因,无法从feature/one剪切feature/two Its not possible to do this and then rebase to develop ! 这是不可能的,然后重新develop

I'm hoping git has a nifty command-line (or set of commands) that I can run that basically tell git to cut feature/two from develop and apply all the same changes to it that exist in feature/one . 我希望git可以运行一个漂亮的命令行(或命令集),基本上告诉git从develop剪切出feature/two develop 并将其应用到feature/one中存在的所有相同更改。

Otherwise, I am going to be ( painstakingly ) copying and pasting changes out of feature/one and into feature/two manually, which will be extremely time-consuming, burdensome and error prone! 否则,我将( 辛苦地 )将更改手动复制并粘贴到feature/one并手动复制到feature/two ,这将非常耗时,麻烦且容易出错!

Any options here for me?! 这里有我的选择吗? Looking for specific commands to run! 寻找要运行的特定命令!

git checkout develop
git pull
git checkout -b feature/two
??? now, how to make feature/two look like feature/one so I can keep adding to it?

Thanks in advance! 提前致谢!

git checkout feature/two
git merge feature/one

This should merge all code changes from feature/one into feature/two. 这应该将所有代码更改从功能/一个合并到功能/两个。

You can read more about it here . 您可以在此处了解更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM