Extracted from here: Force git to add dotfiles to repository
“dot files” are not excluded by default, but maybe some bit of
configuration on your system, repository, or working tree has them set
that way. If they show up in git ls-files --exclude-standard -oi then
they are being ignored and "!.*" is the right way to ‘unignore’ them.
But to be effective, that pattern has to be in the right place.
Ignores are processed in this order:
.gitignore of the immediately containing directory, then
.gitignore of the parent directory (each parent, up to the repository root), then
$GIT_DIR/info/exclude, then
the file reported by git config core.excludesfile (which could be set by
$GIT_DIR/config,
$HOME/.gitconfig, or
the system config file (try GIT_EDITOR=echo git config --system --edit to get its pathname)).
Or add them specifically by pathname, e.g.,
git add */.*
or
find . -name '.[a-z]*' -exec git add '{}' ';'
If nothing of this work, another (maybe not very beautiful) solution is trying with creating a symbolic link like:
ln -s ./idea ./.idea
Hope it helps!