A gitignore that doesn't modify the project code

I notice that when I convert an app into a RubyMine project, the root .gitignore file is modified with the addition of "/.idea/". This modification then gets saved into git so that everyone gets the modification to their .gitignore.

I think there is a far simpler and better option. Add a .ignore file to the .idea directory with this content (.idea/.ignore):

*.* */**/*.*



The advantage of this approach is that it is invisible to the rest of the project and everyone else working on the project. It means that project .gitignore does not get cluttered up with everyone's chosen IDE exclusion code. It also means your are not vulnerable to someone else deciding to tidy up the root .gitignore, and suddenly making your RubyMine project files visible to git.
8 comments
Comment actions Permalink

Hi Rob,

I've tried to open one of git project in RM and see no modifiactions in the sources.
What RM version are you using?  Could you please describe steps to reproduce the problem.

With best regards, Oleg.

0
Comment actions Permalink

Sorry, I can't reproduce the addition of  '/.idea/' into my root .gitignore file. Subsequent projects don't seem to be getting this modification.

I'm just starting with RubyMine, and something I did during adding my first project, entered '/.idea/' into the root .gitignore file. It's not a pattern I use, so I know I didn't put it in manually. However, as I can't tell you what I did to put it in, I'd suggest you don't go on looking for it.

I did search through this forum and all the suggestions were to modify the root .gitignore. I think adding a .gitignore to the .idea folder is a better solution, so perhaps you can look at this as suggestion for updating the documentation.

0
Comment actions Permalink

Let me know if you find the sequence which causes modification of .gitignore.

As for adding .ignore file: could you please point to the documentation about this.  AFter quick seach I was not able to find it :(

Regards, Oleg.

0
Comment actions Permalink

These discussions all describe modifying the root .gitignore file, rather than adding a .gitignore file to the .idea folder:

http://devnet.jetbrains.net/docs/DOC-1192

http://devnet.jetbrains.net/message/5299816#5299816

http://youtrack.jetbrains.com/issue/IDEA-87593

0
Comment actions Permalink

BTW, The file should be .idea/.gitignore and NOT .idea/.ignore

0
Comment actions Permalink

Hi Rob,

I'm not the biggest expert in git thus could you please clarify why adding .gitignore file to .idea would cause git to ignore the directory?
I had impression that .gitignore should be placed in the root of a repository.  And I have found no documentation that it can be placed in any directory :(

Regards, Oleg.

0
Comment actions Permalink

From github help:

"Note that you can create a

.gitignore
in any subpath to have its rules applied at that path."

git does not track empty folders. That's why a .gitkeep file often gets added to some empty folders (for example, test/integration). If the .gitkeep was left out, those folders wouldn't be tracked and when someone cloned the app, their copy would not include the empty folders.

So if you add to a folder a .gitignore that instructs git to ignore all the files and subfolders at that point, git will ignore those file and therefore see the folder as empty and not track the folder either.

*.*         --> all files in this folder
*/**/*.*    --> all files in any subfolder



One of the advantages of this is that the .gitignore that includes the instruction to ignore the folder, is itself ignored. So doesn't get tracked, and therefore your exclusion does not alter the project code for other users (who may or may not use the same IDE). That is, your choice of IDE does not affect the project code.
0
Comment actions Permalink

Thank you for information.

Oleg.

0

Please sign in to leave a comment.