Git 不使用 .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*
I’m working with Rails and added the directory tmp and the Gemfile to my .gitignore. But every time I change it, git status
tells me, that it changed. On both machines. On my developer machine and on the server. Kind of annoying.
Contents of .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*
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
git 可能已经在跟踪文件了。尝试
git rm
操作它们:(尽管您可能应该版本控制下的 Gemfile)
,对于 tmp 目录:
--cached
是为了使工作文件不会被删除,-r
是从一个目录中递归地删除目录。此后 git 应该尊重
.gitignore
。It could be that git is already tracking the files. Try
git rm
ing them:(although you probably should have the Gemfile under version control)
and for the tmp dir:
the
--cached
is so that the working file will not be deleted, and-r
is to recursively remove from a directory.After this git should respect
.gitignore
.如果你的 tmp 和 GemFile 目录已经被版本化,Git 不会忽略它们。
要么取消它们的版本,通过执行类似以下操作:(
--cached 以便它们保留在您的工作目录中)
,或者忽略它们不会被忽略(:)),或者执行类似以下操作:
上述命令“暂时忽略”对已版本化的文件夹。
If your tmp and GemFile directories are already versioned, Git will not ignore them.
Either unversion them, by doing something like:
( --cached so that they will remain in your working directory)
, or ignore that they are not ignored ( :) ) or do something like:
The above command "temporarily ignores" the changes to the folders that are already versioned.