简体   繁体   English

尽管.gitignore和rm -r --cached,git仍然显示文件未跟踪。 我做错了什么?

[英]git still shows files as untracked despite .gitignore and rm -r --cached. What did I do wrong?

I'm not sure what I'm doing wrong in this case with my .gitignore file, but these files keep showing up. 在这种情况下,我不确定我的.gitignore文件出了什么问题,但这些文件一直在显示。

Background 背景

I'm using Jekyll to build a blog. 我正在使用Jekyll建立一个博客。 Jekyll generates _site and .sass-cache directories when it begins serving. Jekyll在开始提供时会生成_site.sass-cache目录。

I previously committed these directories before realizing I wanted to ignore them. 我之前提交过这些目录,然后才意识到我想忽略它们。

To be overly cautious, I added all of the following lines to my .gitignore : 为了过于谨慎,我将以下所有行添加到我的.gitignore

##Jekyll
/_site/
_site/
_site
/.sass-cache/
.sass-cache/
.sass-cache

Since I knew I'd committed these files previously, I: 既然我知道我之前提交过这些文件,我:

  • Committed the updated .gitignore file. 提交了更新的.gitignore文件。
  • did a git rm -r --cached . 做了一个git rm -r --cached .
  • deleted the _site and .sass-cache folders 删除了_site.sass-cache文件夹
  • ran a git add . 跑了一个git add . and git status showed that the working directory was clean git status显示工作目录是干净的

Problem 问题

Despite all of that, the updated .gitignore file, and verifying (I think?) that things are clean and good, whenever I run bundle exec jekyll serve and jekyll generates the files, I see .sass-cache and _site show up in my untracked files. 尽管如此,更新的.gitignore文件,并验证(我认为?)事情是干净和良好的,每当我运行bundle exec jekyll serve和jekyll生成文件时,我看到.sass-cache_site出现在我的未跟踪的文件。

Question

  • What am I doing wrong here? 我在这做错了什么? Is my .gitignore formed improperly? 我的.gitignore是不正确的?
  • How can I ensure that git never shows these directories in the untracked list? 如何确保git永远不会在未跟踪列表中显示这些目录?

The .gitignore in its current state can be found here . 可以在此处找到当前状态的.gitignore。

Your .gitignore file is currently detected as UTF-16LE encoded. 您的.gitignore文件当前被检测为UTF-16LE编码。 Changing encoding to UTF-8 is the solution. 将编码更改为UTF-8是解决方案。

To fix: 修理:

  • Open the .gitignore file in a text editor such as Notepad++ 在Notepad ++等文本编辑器中打开.gitignore文件
  • Change the encoding (in np++, this is via the Encoding menu) to UTF-8 without BOM 将编码(在np ++中,这是通过Encoding菜单)更改为没有BOM的UTF-8
  • Save the file. 保存文件。
  • Add the .gitignore file into staging 将.gitignore文件添加到暂存中
  • git commit -m "fixed ignore file"

At this point, the ignore file should start working correctly. 此时,ignore文件应该开始正常工作。

暂无
暂无

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

相关问题 即使使用“git rm -r --cached”,.gitignore 也不会跟踪我的文件。 和“git add。”? - .gitignore Doesn't Track my Files Even After Using “git rm -r --cached .” and “git add .”? .gitignore和git rm --cached不会阻止文件被跟踪 - .gitignore and git rm --cached wont keep files from being tracked 尽管`rm --cached` .gitignore 被忽略? - .gitignore being ignored despite `rm --cached`? git 中未跟踪的文件不是.gitignore 的一部分 - Files untracked in git not part of .gitignore 我如何进行'git status',以便在不使用.gitignore的情况下不显示未跟踪的文件? - How do I do a 'git status' so it doesn't display untracked files without using .gitignore? 当我执行 git 状态时,My.gitignore 文件显示为未跟踪的文件。 这是正常的吗? - My .gitignore file shows up as an untracked file when I do a git status. Is this normal? git rm - 缓存.gitignore中列出的所有内容 - git rm --cached everything that is listed in .gitignore 你如何git显示.gitignore中不存在的未跟踪文件 - How do you git show untracked files that do not exist in .gitignore npm-debug.log位于.gitignore文件中,但我仍然收到消息“没有添加任何内容来提交但存在未跟踪的文件(使用” git add”进行跟踪)” - npm-debug.log is in .gitignore file, but I still get the messsage “nothing added to commit but untracked files present (use ”git add“ to track)” .gitignore 不起作用 - 仍将文件夹显示为未跟踪 - .gitignore is not working - still shows folders as untracked
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM