sopehl
sopehl

Reputation: 1139

how can i ignore the .idea folder in .gitignore file?

I ignored the .idea folder(for intellij IDE), all file and folder that is in the .idea is removed. I am seeing the .idea in intellij but no this folder in github. And also when i clone this project there is no again .idea, because of it this project is not working on intellij idea project. I am not adding new developer.

Upvotes: 1

Views: 1588

Answers (1)

Anshul Goyal
Anshul Goyal

Reputation: 77073

Git doesn't track directories, it tracks only files. When you untrack all files from within a directory, you are in essence untracking the directory as well.

If you want to keep the directory around in your repository on other machines, while ignoring all the files within it, you could add an empty dummy .gitkeep file.

However, since the desired behavior is to not track any files within the directory, we can use a directory specific .gitignore as the dummy file here which has a single ignore rule for ignoring everything.

So, basically, this translates into the following commands:

$ cd $PROJECT_DIR
$ echo "*" >> .idea/.gitignore
$ git add -f .idea/.gitignore && git commit -m "Ignoring all files within .idea"

Upvotes: 2

Related Questions