<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <author>
    <name>SLIGHTNING</name>
  </author>
  <generator uri="https://hexo.io/">Hexo</generator>
  <id>https://slightning.site/</id>
  <link href="https://slightning.site/" rel="alternate"/>
  <link href="https://slightning.site/atom.xml" rel="self"/>
  <rights>All rights reserved 2026, SLIGHTNING</rights>
  <title>SLIGHTNING 的编程日记</title>
  <updated>2026-07-15T08:17:33.995Z</updated>
  <entry>
    <author>
      <name>SLIGHTNING</name>
    </author>
    <content>
      <![CDATA[<h2 id="现象"><a href="#现象" class="headerlink" title="现象"></a>现象</h2><p>Git 默认是大小写不敏感的，这意味着单纯地更改文件的大小写是不能被检测到的。</p><p>例如：假如有一个文件原本在文件夹 menu 中，现将 menu 文件夹重命名为 Menu，Git 默认不能检测到这一更改。</p><figure class="highlight pwsh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><code class="hljs pwsh"><span class="hljs-built_in">PS</span> D:\test&gt; git status<br>On branch main<br><br>No commits yet<br><br>Changes to be committed:<br>  (use <span class="hljs-string">&quot;git rm --cached &lt;file&gt;...&quot;</span> to unstage)<br>        new file:   src/components/menu/.gitkeep<br><br><span class="hljs-built_in">PS</span> D:\test&gt; <span class="hljs-built_in">Rename-Item</span> src/components/menu Menu<br><span class="hljs-built_in">PS</span> D:\test&gt; git status<br>On branch main<br><br>No commits yet<br><br>Changes to be committed:<br>  (use <span class="hljs-string">&quot;git rm --cached &lt;file&gt;...&quot;</span> to unstage)<br>        new file:   src/components/menu/.gitkeep<br><br></code></pre></td></tr></table></figure><p>要让 Git 检测文件名大小写的变化，需要设置 Git 大小写敏感。</p><h2 id="设置-Git-设置文件名大小写敏感"><a href="#设置-Git-设置文件名大小写敏感" class="headerlink" title="设置 Git 设置文件名大小写敏感"></a>设置 Git 设置文件名大小写敏感</h2><p>在工作区中执行命令：</p><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs sh">git config core.ignorecase <span class="hljs-literal">false</span><br></code></pre></td></tr></table></figure><p>或设置全局大小写敏感：</p><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs sh">git config --global core.ignorecase <span class="hljs-literal">false</span><br></code></pre></td></tr></table></figure><p>设置完之后，Git 就能够检测到重命名后的文件了。</p><figure class="highlight pwsh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><code class="hljs pwsh"><span class="hljs-built_in">PS</span> D:\test&gt; git status<br>On branch main<br><br>No commits yet<br><br>Changes to be committed:<br>  (use <span class="hljs-string">&quot;git rm --cached &lt;file&gt;...&quot;</span> to unstage)<br>        new file:   src/components/menu/.gitkeep<br><br>Untracked files:<br>  (use <span class="hljs-string">&quot;git add &lt;file&gt;...&quot;</span> to include <span class="hljs-keyword">in</span> what will be committed)<br>        src/components/Menu/<br><br></code></pre></td></tr></table></figure><p>但是，此时 Git 并没有检测到重命名之前的文件已经不存在了。在上面的 <code>git status</code> 的输出中，可以看到 Git 没有检测到 <code>src/components/menu/.gitkeep</code> 被删除。在执行 <code>git add .</code> 后，重命名前的文件记录也不会被 Git 删除。</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><code class="hljs plaintext">PS D:\test&gt; git add .<br>PS D:\test&gt; git status<br>On branch main<br><br>No commits yet<br><br>Changes to be committed:<br>  (use &quot;git rm --cached &lt;file&gt;...&quot; to unstage)<br>        new file:   src/components/Menu/.gitkeep<br>        new file:   src/components/menu/.gitkeep<br><br></code></pre></td></tr></table></figure><p>尽管有些方法可以暂时解决这一问题（参见参考资料 1），但是这些方法太过麻烦。</p><p>Git 之所以识别不到重命名前的文件已被删除，是因为 Windows 默认不区分文件文件名的大小写，所以，只要将 Windows 文件路径设置为大小写大小写敏感，就可以彻底解决这一问题。</p><h2 id="Windows-设置文件名大小写敏感"><a href="#Windows-设置文件名大小写敏感" class="headerlink" title="Windows 设置文件名大小写敏感"></a>Windows 设置文件名大小写敏感</h2><p>在 Windows 10 1803 或更高版本中，可以用 <code>fsutil</code> 命令对指定目录开启文件名大小写敏感（可能需要启用 WSL）。</p><p>使用管理员权限 PowerShell 运行：</p><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs sh">fsutil file setCaseSensitiveInfo &lt;路径&gt; <span class="hljs-built_in">enable</span><br></code></pre></td></tr></table></figure><p>执行完后，该路径下新建立的文件夹仍是大小写敏感的，但是原先已经存在的文件夹不会发生改变。</p><p>要使原先存在的文件夹也是大小写敏感的，可以递归设置：</p><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs sh">Get-ChildItem &lt;路径&gt; -Recurse -Directory | % &#123; fsutil file setCaseSensitiveInfo <span class="hljs-string">&quot;<span class="hljs-subst">$($_.FullName)</span>&quot;</span> <span class="hljs-built_in">enable</span> &#125;<br></code></pre></td></tr></table></figure><p>设置完后，Git 就能正常识别大小写了。</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><code class="hljs plaintext">PS D:\test&gt; git status<br>On branch main<br><br>No commits yet<br><br>Changes to be committed:<br>  (use &quot;git rm --cached &lt;file&gt;...&quot; to unstage)<br>        new file:   src/components/Menu/.gitkeep<br>        new file:   src/components/menu/.gitkeep<br><br>Changes not staged for commit:<br>  (use &quot;git add/rm &lt;file&gt;...&quot; to update what will be committed)<br>  (use &quot;git restore &lt;file&gt;...&quot; to discard changes in working directory)<br>        deleted:    src/components/menu/.gitkeep<br><br></code></pre></td></tr></table></figure><p>启用文件大小写敏感后会产生一些问题：</p><ul><li>位于 <code>node_modules/.bin</code> 目录中的命令可能无法识别，对该目录关闭大小写敏感即可。</li><li>VS Code 可能识别不到重命名后的文件，重启 VS Code 即可。</li></ul><h2 id="参考资料"><a href="#参考资料" class="headerlink" title="参考资料"></a>参考资料</h2><ol><li><a href="https://juejin.cn/post/7029305262439677982">Git 文件名称大小写的天坑 - 掘金</a></li><li><a href="https://zhuanlan.zhihu.com/p/479689927">Windows 10 开启文件名大小写敏感功能 - 知乎</a></li></ol>]]>
    </content>
    <id>https://slightning.site/pitfalls/git-ignore-case-on-windows/</id>
    <link href="https://slightning.site/pitfalls/git-ignore-case-on-windows/"/>
    <published>2026-06-21T02:08:54.000Z</published>
    <summary>太坑了。</summary>
    <title>Windows 系统上的 Git 文件名大小写问题</title>
    <updated>2026-07-15T08:17:33.995Z</updated>
  </entry>
  <entry>
    <author>
      <name>SLIGHTNING</name>
    </author>
    <content>
      <![CDATA[<p>Welcome to <a href="https://hexo.io/">Hexo</a>! This is your very first post. Check <a href="https://hexo.io/docs/">documentation</a> for more info. If you get any problems when using Hexo, you can find the answer in <a href="https://hexo.io/docs/troubleshooting.html">troubleshooting</a> or you can ask me on <a href="https://github.com/hexojs/hexo/issues">GitHub</a>.</p><h2 id="Quick-Start"><a href="#Quick-Start" class="headerlink" title="Quick Start"></a>Quick Start</h2><h3 id="Create-a-new-post"><a href="#Create-a-new-post" class="headerlink" title="Create a new post"></a>Create a new post</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">$ hexo new <span class="hljs-string">&quot;My New Post&quot;</span><br></code></pre></td></tr></table></figure><p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p><h3 id="Run-server"><a href="#Run-server" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">$ hexo server<br></code></pre></td></tr></table></figure><p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p><h3 id="Generate-static-files"><a href="#Generate-static-files" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">$ hexo generate<br></code></pre></td></tr></table></figure><p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p><h3 id="Deploy-to-remote-sites"><a href="#Deploy-to-remote-sites" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">$ hexo deploy<br></code></pre></td></tr></table></figure><p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>]]>
    </content>
    <id>https://slightning.site/hello-world/</id>
    <link href="https://slightning.site/hello-world/"/>
    <published>2026-06-21T01:49:05.000Z</published>
    <summary>开始使用 Hexo。</summary>
    <title>Hello World</title>
    <updated>2026-07-15T08:17:33.995Z</updated>
  </entry>
</feed>
