将大块重新组织成提交
我对一些代码进行了重大重构,并且在这个过程中我已经提交了几次。这还没有被推送到任何公共仓库。在推送之前,我现在想将提交重新组织为逻辑单元。问题是我不仅想压缩提交,还想将这些块重新组织到其他提交中。
为了说清楚,我已经与帅哥 A1、A2、A3 提交了 A,并与帅哥 B1、B2、B3 提交了 B。我想检查 A 之前的版本,并有新的提交 C 和大块头 A1、A2、B2 以及新的提交 D 和大块头 B1、B3、A3。
提前致谢。
I have made a major refactoring of some code, and in the process I have commited several times. This has not been pushed to any public repo yet. Before pushing, I would like now reorganize the commits into logical units. The problem is that I want not only to squash commits but to reorganze the hunks into other commits.
Just to make it clear, I have commit A with hunks A1, A2, A3, and commit B with hunks B1, B2, B3. I want to checkout the version previous to A and have new commit C with hunks A1, A2, B2 and a new commit D with hunks B1, B3, A3.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看
git rebase
、拆分提交。Take a look at
git rebase
, splitting commits.听起来您想要一组完全不同的提交。如果是这种情况,只需返回到原点(例如 git reset origin/master),然后重复使用 git add -p 和 git commit 直到完成。如果需要,您可以在提交后使用 git stash 测试每个提交,并使用 git --amend 修复任何错误。
或者, git rebase -i 实际上可以拆分提交。阅读手册页,这并不难,但有点麻烦。
It sounds like you want a completely different sets of commits. If that is the case, simply got back to the origin (e.g. git reset origin/master), and then use git add -p and git commit repeatedly until you are done. You can use git stash to test each commit after committing, if desired, and use git --amend to fix any mistakes.
Alternatively, git rebase -i can actually split commits. Read the man page, it's not hard but a bit bothersome.