git 如何在 IDEA 中将一组本地提交组合到单次推送?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26898511/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 02:39:48  来源:igfitidea点击:

How to combine group of local commits to single push in IDEA?

gitintellij-ideapushcommit

提问by gstackoverflow

In IDEA I am trying to push some commits.

在 IDEA 中,我试图推动一些提交。

I have a requirement that on remote server it looks like single action.

我有一个要求,在远程服务器上它看起来像一个单一的动作。

I click to push and see following window enter image description here

我点击推送并看到以下窗口 在此处输入图片说明

I expected to see squash checkbox here but don't see it.

我希望在这里看到壁球复选框,但没有看到。

Please help me.

请帮我。

回答by Bohuslav Burghardt

You can do it using rebase. Go to VCS/Git/Rebase. Then select Interactiveoption. It will show you a list of commits, where you can pick which ones you want to squash.

你可以使用 rebase 来做到这一点。转到VCS/Git/Rebase。然后选择交互选项。它将向您显示提交列表,您可以在其中选择要压缩的提交。

After you hit Start rebasingit will prompt you for a commit message for the squashed commit. After that is done you can push your squashed commit using push dialog.

点击Start rebase 后,它会提示您输入压缩提交的提交消息。完成后,您可以使用推送对话框推送压缩的提交。

Squash dialog

壁球对话框

More information about rebase in IntelliJ is here.

有关 IntelliJ 中 rebase 的更多信息在这里

回答by ValentinVoilean

There is a new way:

有一个新方法:

Version Control -> Log -> Right click on the commit -> Interactively rebase from hereand then you can choose to pick/squash the rest of commits.

版本控制 -> 日志 -> 右键单击​​提交 ->Interactively rebase from here然后您可以选择选择/压缩其余的提交。

回答by Oussama Zoghlami

For me the simplest way with intellij is :

对我来说,intellij 最简单的方法是:

  • Go to Logtab and chose the commit from which you want to squash
  • Right click and select Reset Branch to this commit
  • Choose the mixinoptions to keep your changes from the commit
  • Commit your changes and don't forget to check the Amend commitoption
  • 转到Log选项卡并选择要压缩的提交
  • 右键单击并选择 Reset Branch to this commit
  • 选择mixin选项以防止提交更改
  • 提交您的更改,不要忘记检查Amend commit选项