DEV Community

loading...

Git merge without commit in IntelliJ

itzg profile image Geoff Bourne ・2 min read

By default, using the git merge (not rebase) operation in IntelliJ will immediately create a merge-commit. Sometimes you may want to selectively revert changes or alter content before concluding the merge.

Using either the "Git" menu or version control status area in the bottom right of the project window, checkout the destination branch of the merge:

Alt Text
or
Alt Text

Use the "Git -> Merge" menu to bring up the following window. There's many options in this window, which simplify the command-line equivalents. In any scenario, first choose the source branch from the dropdown:

Alt Text

Remove any options you already have:

Alt Text

and add the --no-commit option:

Alt Text

Click the "Merge" button to proceed.

The "Commit" tool window will show the merge changes, but not yet selected/staged for commit:

Alt Text

At this point you can edit files as normal, selectively revert lines from the diffs...

Alt Text

...or rollback/revert entire files:

Alt Text

Select/stage the changes from the "Commit" tool window and proceed with the merge's commit as you normally would.

Looking at the "Git" tool window's "Log" tab, the merge-commit appears as it should:

Alt Text

Discussion (0)

pic
Editor guide