IntelliJ - Reformatting code before you commit it

Table of Contents

Reformatting Before Commit

https://www.jetbrains.com/guide/java/tutorials/reformatting-code/reformatting-before-commit/

If you always want to reformat code in a Project before you commit it, you can do this with the cog in the Commit tool window which is invoked with ⌘0 (macOS) / Alt+0 (Windows/Linux):

  1. File -> Settings -> Version Control -> Commit -> Commit Checks -> Reformat Code
  2. File -> Settings -> Version Control -> Commit -> Commit Checks -> Optimize imports