2

I want to add the .idea folder to git (unlike most devs who want to ignore it). I have tried all the solutions at:

Recursively add the entire folder to a repository

but nothing worked. My gitignore only has this:

**/build/ .gradle

I'm at a loss of why none of the files get added.

Johann
  • 27,536
  • 39
  • 165
  • 279

1 Answers1

1

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!

JP. Aulet
  • 4,375
  • 4
  • 26
  • 39