为以前的提交创建 git 分支:最好的方法是什么?
想象一下以下情况:
- 在“development”分支上完成了一堆相关的提交
- 这些提交实际上应该是在“feature_x”分支上完成的
- “feature_x”分支应该合并到“development”分支
图形示例:
当前情况:
development (HEAD) A--B--C--D--E
期望情况:
development A--B
\
feature_x C--D--E
如何创建此功能分支,将这些先前的提交分组到该分支中,并创建“开发”分支看起来像没有对它进行任何个人提交?
Imagine the following:
- A bunch of related commits are done on a 'development' branch
- These commits should have actually been done to a 'feature_x' branch
- The 'feature_x' branch should be merged into the 'development' branch
Graphed example:
Current situation:
development (HEAD) A--B--C--D--E
Desired situation:
development A--B
\
feature_x C--D--E
How do I create this feature branch, group these previous commits into the branch, and make the 'development' branch look like no individual commits have been done to it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你真的不需要太多:
You don't really need much to to that:
我假设你想变得像这样
你可以使用 git rebase
在 dev 分支的 HEAD 上 执行此操作
创建一个临时分支用于变基目的
将您的开发分支移动到提交 A
将您的功能分支移动到提交 E 并删除临时分支
I assume you want to become like this
You can use
git rebase
to do thison the HEAD of dev branch
create a temp branch for rebasing purpose
move your devbranch to commit A
move your feature branch to commit E and delete temp branch