如何创建一个兄弟分支,其中包含从另一个分支到一个节点的所有提交?
我有一个分支 mybranch,它有 6 个提交,源自提交 C。我想创建一个新分支,也基于提交 C,它有效地包含来自 mybranch 的所有提交,并压缩为一个提交。做到这一点最简单的方法是什么?
由于“在 git-push 之前压缩”的口头禅,我需要这样做。对于新分支,我不希望在推送到远程服务器的历史记录中提及 mybranch。我想创建一个用于推送的全新分支的原因是因为我想保留 mybranch 中的所有提交以供参考。
I have a branch, mybranch, that has six commits and stems from commit C. I would like to create a new branch, also based on commit C, that effectively includes all the commits from mybranch, squashed into one commit. What's the easiest way to do this?
I need to do this due to the mantra of "squash before you git-push". For the new branch, I don't want any mention of mybranch in the history pushed up to the remote server. The reason I want to create a whole new branch used to push is because I'd like to keep all the commits in mybranch for reference.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么只推送压缩的提交?这听起来很疯狂(而且是错误的)。
但要回答你的问题:
另一种可能性是使用
rebase -i
将所有提交压缩/修复为单个提交:同样有趣的是
git merge --squash
:Why only push squashed commits? That sounds crazy (and wrong).
But to answer your question:
Another possibility would be to use
rebase -i
to squash/fixup all commits into a single one:Also of interest is
git merge --squash
: