Git 没有使用 .gitignore 的内容

标签 git ruby-on-rails-3 gitignore

我正在使用 Rails,并将目录 tmp 和 Gemfile 添加到我的 .gitignore。但是每次我更改它时,git status 都会告诉我,它发生了变化。在两台机器上。在我的开发机器和服务器上。有点烦人。

.gitignore 的内容:

.DS_Store
data/export/*.csv
tmp/*
*.rbc
*.sassc
.sass-cache
capybara-*.html
.rspec
/.bundle 
/vendor/bundle 
/log/* 
/tmp/* 
/db/*.sqlite3 
/public/system/* 
/coverage/ 
/spec/tmp/* 
**.orig 
config/*.yml 
rerun.txt 
pickle-email-*.html 
Gemfile*

最佳答案

可能是 git 已经在跟踪这些文件。尝试 git rm对他们:

git rm --cached Gemfile

(尽管您可能应该将 Gemfile 置于版本控制之下)

对于 tmp 目录:

git rm -r --cached tmp

--cached是工作文件不会被删除,-r是递归地从目录中删除。

在此之后 git 应该遵守 .gitignore

关于Git 没有使用 .gitignore 的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5810233/

相关文章:

gitignore 无法与 Visual Studio 一起使用

laravel-5 - 将代码推送到实时站点时,laravel 符号链接(symbolic link)会更改

git - git log 向我显示了什么?

git - 在 git 中检查远程分支时遇到问题

php - 创建一个新的社交网站。推荐的启动框架?

ruby-on-rails-3 - 无法 headless 运行 Jasmine 规范

GIT - 跨平台涂抹/清洁过滤器?

git - 有没有办法在没有嵌套子模块的情况下添加 git 子模块?

ruby-on-rails-3 - 如何在 gem 中覆盖 Rails 生成器模板?

git - 将 .gitignore 添加到 Repo 的最佳实践