How to configure gitignore?

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

/.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 that does not work. What's wrong?

+7
source share
3 answers

What you did is right. You may have already added these files before you make .gitignore.

So try this

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

Then check if the files you put in ignore are added to the index. Or you can change them and see if they are tracked.

+7
source

If these files have already been added to the index, you must first delete them.

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

Then .gitignore can work with these files.

+3
source

If "database.yml" is added to your git repository before you specify it in the ignore file, I think you should delete it:

 git rm config/database.yml git commit -a -m "Removed database.yml" 

Then add the database.yml file to your project, it will work fine.

+1
source

All Articles