尽管使用.gitignore和rm -r --cached,git仍然显示未跟踪的文件。我做错了什么? [英] git still shows files as untracked despite .gitignore and rm -r --cached. What did I do wrong?

查看:537
本文介绍了尽管使用.gitignore和rm -r --cached,git仍然显示未跟踪的文件。我做错了什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定我在这种情况下使用.gitignore文件做错了什么,但这些文件一直显示出来。



背景



我正在使用Jekyll建立一个博客。 Jekyll生成 _site .sass-cache 目录。



我以前在实现我想忽略它们之前提交了这些目录。



为了过于谨慎,我将以下所有行添加到

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

因为我知道我之前已经提交了这些文件,所以我:


  • 承诺更新后的 .gitignore 文件。
  • 删除了 _site .sass-cache 文件夹 / li>
  • 运行了 git add。 git status 显示工作目录是干净



问题



尽管如此,更新后的.gitignore文件,并验证(我认为?)那件事每当我运行 bundle exec jekyll serve 和jekyll生成文件时,我会看到 .sass-cache _site 显示在我未跟踪的文件中。



问题




  • 我在这里做错了什么?我的.gitignore形成不当吗?


  • $ b


  • .gitignore处于当前状态可在此处找到

    当前检测到您的 .gitignore 文件为UTF-16LE编码。改变编码为UTF-8是解决方案。



    解决:


    • 在记事本++等文本编辑器中打开.gitignore文件
    • 更改编码(在np ++中,这是通过 Encoding 菜单)转换为UTF-8,不含BOM

    • 保存文件

    • 将.gitignore文件添加到分段中
    • git commit -mfixed ignore file


    此时,忽略文件应该开始正常工作。


    I'm not sure what I'm doing wrong in this case with my .gitignore file, but these files keep showing up.

    Background

    I'm using Jekyll to build a blog. Jekyll generates _site and .sass-cache directories when it begins serving.

    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:

    ##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.
    • did a git rm -r --cached .
    • deleted the _site and .sass-cache folders
    • ran a git add . and git status showed that the working directory was clean

    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.

    Question

    • What am I doing wrong here? Is my .gitignore formed improperly?
    • How can I ensure that git never shows these directories in the untracked list?

    The .gitignore in its current state can be found here.

    解决方案

    Your .gitignore file is currently detected as UTF-16LE encoded. Changing encoding to UTF-8 is the solution.

    To fix:

    • Open the .gitignore file in a text editor such as Notepad++
    • Change the encoding (in np++, this is via the Encoding menu) to UTF-8 without BOM
    • Save the file.
    • Add the .gitignore file into staging
    • git commit -m "fixed ignore file"

    At this point, the ignore file should start working correctly.

    这篇关于尽管使用.gitignore和rm -r --cached,git仍然显示未跟踪的文件。我做错了什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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