Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to config gitignore?

I want to ignore some of my files (/config/environments/production.rb , /webrat.log , /config/database.yml ). My gitignore:

/.bundle
/db/*.sqlite3
/doc/
*.rbc
*.sassc
.sass-cache
capybara-*.html
.rspec
/vendor/bundle
/log/*
/tmp/*
/public/system/*
/coverage/
/spec/tmp/*
**.orig
rerun.txt
pickle-email-*.html

/config/environments/production.rb
/config/*.yml
/*.log

But this doesn't work. What's wrong?

like image 419
user1466717 Avatar asked Jun 21 '12 19:06

user1466717


2 Answers

What you did is correct. Probably you have already added these files, before making .gitignore.

So Try this

git rm -r --cached .   (Note the period at the end.)
git add .

Then check whether the files that you put in ignore is still added to the index. Or you could modify them and check whether they are being tracked.

like image 60
vincent mathew Avatar answered Sep 28 '22 02:09

vincent mathew


If those files were already added to the index, you need to remove them first.

git rm --cache /config/environments/production.rb
git rm --cache /webrat.log 
git rm --cache /config/database.yml 

Then the .gitignore can work on those files.

like image 33
VonC Avatar answered Sep 28 '22 03:09

VonC