简体   繁体   English

git正在忽略不在.gitignore中的文件?

[英]git is ignoring files that aren't in .gitignore?

Solved: Decided to delete the .git directory and try again, since there was nothing in it anyway. 已解决:决定删除.git目录,然后重试,因为无论如何都没有。 rm -rf .git , then git init , then git add . rm -rf .git ,然后是git init ,然后是git add。 . Now it's working, everything is getting added correctly, and things that should be ignored are. 现在它可以正常工作了,一切都正确添加了,应该忽略的事情了。 Think I mis-cloned 960gs or html5boilerplate into the project directory instead of a subdirectory. 认为我将960gs或html5boilerplate错误地克隆到了项目目录而不是子目录中。 Thanks everyone for your replies, much appreciated. 感谢大家的答复,非常感谢。


There are lots of questions on SO about git failing to ignore files specified in .gitignore. 因此,关于git无法忽略.gitignore中指定的文件,有很多问题。 My problem is the exact opposite - git is ignoring files that aren't listed in .gitignore. 我的问题是完全相反的-git忽略了.gitignore 中未列出的文件。

For example, I've just started a web project using HTML5Boilerplate and 960 Grid System , and am trying to do the initial commit. 例如,我刚刚使用HTML5Boilerplate960 Grid System启动了一个Web项目,并尝试进行初始提交。 However, only a few of the files and directories I need are being staged when I run 'git add *'. 但是,当我运行'git add *'时,只有我需要的文件和目录中的几个正在暂存。

.gitignore in the project directory specifies a list of project, vcs, and other files to ignore, but not *.html, *.xml, *.conf, .htaccess, *.ico, *.png files, which are not being staged to the index. 项目目录中的.gitignore指定要忽略的项目,vcs和其他文件的列表,但不指定* .html,*。xml,*。conf,.htaccess,*。ico,*。png文件上演索引。 Strangely, one html file is being added, demo.html, while index.html isn't. 奇怪的是,添加了一个html文件demo.html,而没有添加index.html。

Anyone have any idea what's wrong and how to fix it? 任何人都知道哪里出了问题以及如何解决?

Here's a transcript of the operations for clarity: 为了清楚起见,下面是操作的记录:

%> ls -al
total 136
drwxr-xr-x 13 me me  4096 2010-11-08 14:04 .
drwxr-xr-x  6 me me  4096 2010-11-08 13:23 ..
-rw-r--r--  1 me me   720 2010-11-08 13:21 404.html
-rw-r--r--  1 me me  1893 2010-11-08 13:21 apple-touch-icon.png
drwxr-xr-x  3 me me  4096 2010-11-08 13:21 build
-rw-r--r--  1 me me   802 2010-11-08 13:21 crossdomain.xml
drwxr-xr-x  3 me me  4096 2010-11-08 13:24 css
drwxr-xr-x  2 me me  4096 2010-11-08 13:21 demo
-rwxr-xr-x  1 me me  8920 2010-11-08 13:15 demo.html
-rw-r--r--  1 me me  1150 2010-11-08 13:21 favicon.ico
drwxr-xr-x  8 me me  4096 2010-11-08 14:04 .git
-rw-r--r--  1 me me   266 2010-11-08 13:44 .gitignore
-rw-r--r--  1 me me  8011 2010-11-08 13:21 .htaccess
drwxr-xr-x  2 me me  4096 2010-11-08 13:21 images
drwxr-xr-x  2 me me  4096 2010-11-08 13:15 img
-rw-r--r--  1 me me  3115 2010-11-08 13:21 index.html
drwxr-xr-x  5 me me  4096 2010-11-08 13:21 js
-rw-r--r--  1 me me  5166 2010-11-08 13:21 lighttpd.conf
-rw-r--r--  1 me me  3484 2010-11-08 13:21 mime.types
-rw-r--r--  1 me me  3413 2010-11-08 13:21 nginx.conf
-rw-r--r--  1 me me     0 2010-11-08 14:04 output.txt
-rw-r--r--  1 me me  6277 2010-11-08 13:21 README.markdown
-rw-r--r--  1 me me   107 2010-11-08 13:21 robots.txt
drwxr-xr-x  4 me me  4096 2010-11-08 13:17 templates
drwxr-xr-x  3 me me  4096 2010-11-08 13:21 test
drwxr-xr-x  2 me me  4096 2010-11-08 13:45 vim~
-rw-r--r--  1 me me 12274 2010-11-08 13:21 web.config
drwxr-xr-x  2 me me  4096 2010-11-08 12:09 wireframes

%> less .gitignore
# Numerous always-ignore extensions
*.diff
*.err
*.orig
*.log
*.rej
*.swo
*.swp
*.vi
*~

# OS or Editor folders
.DS_Store
.cache
.project
.settings
nbproject
thumb.db

# Folders to ignore
.hg
.svn
publish
.idea
templates
template

# files
build/buildinfo.properties

%> git add *
# Not currently on any branch.
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   new file:   css/960.css
#   new file:   css/960_24_col.css
#   new file:   css/reset.css
#   new file:   css/rtl_960.css
#   new file:   css/rtl_960_24_col.css
#   new file:   css/rtl_text.css
#   new file:   css/text.css
#   new file:   css/uncompressed/960.css
#   new file:   css/uncompressed/960_24_col.css
#   new file:   css/uncompressed/demo.css
#   new file:   css/uncompressed/reset.css
#   new file:   css/uncompressed/rtl_960.css
#   new file:   css/uncompressed/rtl_960_24_col.css
#   new file:   css/uncompressed/rtl_text.css
#   new file:   css/uncompressed/text.css
#   new file:   demo.html
#   new file:   img/12_col.gif
#   new file:   img/16_col.gif
#   new file:   img/24_col.gif
#   new file:   wireframes/basalmiq01.pdf
#   new file:   wireframes/basalmiq01.png
#   new file:   wireframes/basalmiq01.xml
#   new file:   wireframes/fcf_mockingbird.zip
#   new file:   wireframes/fcf_mockingbird_.zip
#
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   .gitignore
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   output.txt

也许那些文件已经被git控制了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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