11

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.

SeanKilleen
  • 8,809
  • 17
  • 80
  • 133

1 Answers1

14

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.

SeanKilleen
  • 8,809
  • 17
  • 80
  • 133
David Jacquel
  • 51,670
  • 6
  • 121
  • 147
  • Thanks! This was definitely the issue and I'll mark as correct. Just curious: How did you know that it was an encoding issue? Until I opened it in Notepad++ and checked, it wasn't apparent to me. – SeanKilleen Oct 07 '14 at 16:45
  • I first created a new .gitignore from scratch, then guessing that it can be encoding or bom, just checked the original and saw that it was UTF-16LE. An other hint was that the file is seen as a binary file and not a text file. – David Jacquel Oct 07 '14 at 16:58
  • Great! Thank you for the context; that'll be really helpful if I run into this again (never occurred to me that it might happen). – SeanKilleen Oct 07 '14 at 16:59
  • 1
    For those who want do change encoding with `ATOM` use the `convert-file-encoding` package. – Adam Jun 27 '17 at 09:28