Git没有使用.gitignore的内容 [英] Git is not using the contents of .gitignore

查看:226
本文介绍了Git没有使用.gitignore的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Rails,并将目录tmp和Gemfile添加到我的.gitignore中。但每次我改变它时, git status 告诉我,它已经改变了。在两台机器上。在我的开发人员机器和服务器上。

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.

.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

It could be that git is already tracking the files. Try git rming them:

git rm --cached Gemfile

(尽管您可能需要在版本控制下使用Gemfile)

(although you probably should have the Gemfile under version control)

和tmp dir:

git rm -r --cached tmp



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

the --cached is so that the working file will not be deleted, and -r is to recursively remove from a directory.

在这个git应该遵守 .gitignore

After this git should respect .gitignore.

这篇关于Git没有使用.gitignore的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆