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

GitIntellij IdeaPushCommit

Git Problem Overview


In IDEA I am trying to push some commits.

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.

Git Solutions


Solution 1 - Git

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

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

Squash dialog

More information about rebase in IntelliJ is here.

Solution 2 - Git

There is a new way:

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

Solution 3 - Git

For me the simplest way with intellij is :

  • Go to Log tab and chose the commit from which you want to squash
  • Right click and select Reset Branch to this commit
  • Choose the Soft Or Mixin options to keep your changes from the commit
  • Commit your changes and don't forget to check the Amend commit option

Solution 4 - Git

With the latest version of IntelliJ you can simply select all the commits, right-click -> Squash commits

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiongstackoverflowView Question on Stackoverflow
Solution 1 - GitBohuslav BurghardtView Answer on Stackoverflow
Solution 2 - GitValentinVoileanView Answer on Stackoverflow
Solution 3 - GitOussama ZoghlamiView Answer on Stackoverflow
Solution 4 - GitM.PanicciaView Answer on Stackoverflow