DEV Community

Geoff Bourne
Geoff Bourne

Posted on

Re-ordering git commits using IntelliJ

In the "Log" tab of the "Git" tool window, select and right click the revision prior to commits to re-order. Choose "Copy revision number":

Screenshot 2021-01-30 183520

Use the "Git -> Rebase" menu.

Screenshot 2021-01-30 184014

Paste the revision into the text field.

Screenshot 2021-01-30 183940

Remove any other options enabled and add --interactive option:

Screenshot 2021-01-30 184043

Use up/down button to re-order the commits where the commits are ordered top-to-bottom, oldest-to-newest:

Screenshot 2021-01-30 184119

Click "Start rebasing". You will be prompted to resolve any conflicts that might occur due to the re-ordering.

Check out the IntelliJ documentation for more information

Top comments (1)

nicolus profile image
Nicolas Bailly • Edited

A word of warning though : Don't do that (or any other Rebase operation) after you've already pushed if you don't want your coworkers to hate you.

As you'll be rewriting history, you won't be able to simply push and you'll have to "force push" your new history, and basically all your team will need to delete their repo and start from the new one.