rornoob.com >

** in .gitignore



3-Nov-2010

I started working on a new project using git for version control and eclipse RadRails for version control. Wanting to avoid commiting a whole lot of unnecessary files I looked around for an example .gitignore file for rails apps and came across the following:

log/*.log
tmp/**/*
tmp/*
doc/api
doc/app
coverage/*
public/javascripts/all.js
public/stylesheets/all.css
public/system
Gemfile.lock
.bundle

To that I added another entry to exclude the eclipse project file:

.project

So far so good, except that eclipse seemed to be creating a whole lot of extra temporary files that weren't being excluded by the settings above. E.g. things like:

app/views/example/.tmp_index.html.erb.55162~
app/views/example/.tmp_index.html.erb.77831~
app/views/example/.tmp_show.html.erb.88243~
app/views/example/.tmp_update.html.erb.56122~
app/views/example/more/.tmp__mockup.html.erb.7334~
app/views/example/more/.tmp_index.html.erb.97377~
app/views/example/more/.tmp_show.html.erb.52186~

No worries.., I'll just use that double asterix thingy to exclude all .tmp_ files from within my views:

app/views/**/.tmp_*

Nope - no good. The temp files are still there - that ** doesn't seem to be working as expected... One work-around is to list each folder with a */

*/.tmp*
*/*/.tmp*
*/*/*/.tmp*
etc.

That's not very nice. Why wont the ** work? From digging around on forums it seems there are plenty of other people who are also confused about ** in gitignore. Eventually though I stumbled upon an explanation: As soon as there is a / in the text then gitignore uses a different method of working out the paths. So, don't use / with **

**.tmp_*

That's better - the temp files are now ignored. It pays to be careful though - I'm now excluding .tmp_ from more than just my views. In this case that shouldn't be a problem but it's something to bare in mind.

|

del.icio.usDiggblogmarksNewsvineStumbleUponTechnoratiFurlReddit

Add your comment
Name
Website
Heading
Comment