简体   繁体   English

如何在 Git 中将修复提交提升为常规提交?

[英]How to promote a fixup commit to a regular commit in Git?

I have created a fixup commit with code that I now realized should be a regular commit.我已经用代码创建了一个修复提交,我现在意识到应该是一个常规提交。 I don't want to have any surprises on the next rebase - how can I make this fixup commit a regular commit, dis-associating it from the commit ID I tried to "fix"?我不想在下一次 rebase 上有任何惊喜 - 我怎样才能让这个修复提交一个常规提交,将它与我试图“修复”的提交 ID 分离?

A fixup commit (that is, one you create with git commit --fixup ) or a squash commit (one you create with git commit --squash ) are really just regular commits.修复提交(即,您使用git commit --fixup创建的git commit --fixup )或git commit --fixup提交(您使用git commit --squash创建的git commit --squash )实际上只是常规提交。 So if you'd like to turn one of them into a regular commit, just edit its commit message.因此,如果您想将其中一个转换为常规提交,只需编辑其提交消息即可。

  • if the commit is the latest in the branch, use git commit --amend ,如果提交是分支中的最新git commit --amend ,请使用git commit --amend
  • if it's earlier, you can use git rebase -i (without the --autosquash option) to edit the commit message and place it where you'd like it.如果它更早,您可以使用git rebase -i (不带--autosquash选项)来编辑提交消息并将其放在您想要的位置。

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

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