'Intellij stopped auto staging, files no longer highlighted green after changes

Previously working with Intellij it was highlighting files green, that I have changed but not committed yet. Now when I change they are not being highlighted, when try to git commit -m message in terminal I get

Changes not staged for commit:

modified: file.java

no changes added to commit

I have to use commit ctrl + K window, select all changes in the tree, press button to commit and then it works. After changes are committed I am still able to use git push origin in terminal to push.

When I change file I still see a vertical line in green appearing, marking all added code, etc. So change list is working, as I read it, but auto staging turned off?

What do I do to get back to using git commit -m message in terminal ?

Intellij IDEA 2022.1 community edition

UPDATE: I have now tried to add file, which then was highlighted greed, and after that all changes we committed through terminal. Then removed file, and committed again. So another question, committing through git commit -m message available only if files were added/removed, and not in case I have changed logic in existing files?

UPDATE2: As mentioned in update1 new files were always committed through git commit -m message. But it seems that changes in old files were not committed in this way. Committing new files and changes in code from existing files seem to be working through git commit -am message.

Can someone confirm it?



Solution 1:[1]

To use git commit -m message in a terminal you need to stage your changes also in a terminal or enable Staging support in IntelliJ and manually control the staging from the UI.

IntelliJ adds changes to the stage as part of the commit operation, so only once you press the Commit button. One exception is for new files - if the corresponding setting to auto-add new files to VCS is enabled, IJ will call git add when the file appears, but all further modifications to the file will not be staged until the commit button is pressed.

Unless you had some third-party plugins that auto-staged files, IntelliJ has never done so, so I am not sure why it worked previously.

Also, you can auto-stage all changes as part of a commit using the -a flag - git commit -am message.

BTW, why do you want to commit from terminal and not use UI?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1