简体   繁体   中英

Git ignoring my .gitignore on a Rails project

I'm having some deployment problems, due to Rails' tmp/cache/assets folder and git not ignoring tmp/* or tmp/ . My entire .gitignore is:

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

It's taken from GitHub gitignore repo . What can I do to fix it? I get tons of errors due to local changes (in the tmp/ folder) on my server, such as error: Your local changes to 'tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705' would be overwritten by merge. Aborting. error: Your local changes to 'tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705' would be overwritten by merge. Aborting. , so I can't deploy on my dev machine :(

Did you add the .gitignore after starting the project? If tmp/cache/assets/whatever already existed before you added the .gitignore, it'll still be in the repo.

  1. Try a git rm -r tmp && git commit to remove the whole tmp directory from the repo.

  2. Try deploying at this point to see if deployment works from a known-good state. If it still doesn't work, you know there is some other issue.

  3. If everything works, new changes to tmp should no longer be picked up.

ALso, as @thenetimp points out, your current .gitignore will only ignore /tmp , but not something/tmp . I'm not sure if that's your intention or not.

删除/tmp/前面的正斜杠/tmp/它应该是tmp/

Take a look at a sample .gitignore file at: https://github.com/github/gitignore/blob/master/Rails.gitignore

I also found a good article at http://www.wrel.de/gitignore-und-was-kommt-rein/ (German)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM