Is there a way to remove unused imports in Intellij IDEA on commit?
It is not very optimal to do it manually, CTRL + ALT + O helps b
If you are using IntelliJ IDEA or Android Studio:
Go to Settings > Editor > General >Auto Import and check the Optimize imports on the fly checkbox.
File/Settings/Inpsections/Imports
and change "Unused import" to Error. This marks them more clearly in the Inspections gutter and the Inspection Results panel.
You can check checkbox in the commit dialog.
You can use settings to automatically optimize imports since 11.1 and above.