<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Claude Code on 武成龙</title><link>https://orangon.github.io/tags/claude-code/</link><description>Recent content in Claude Code on 武成龙</description><generator>Hugo -- gohugo.io</generator><language>zh-CN</language><lastBuildDate>Fri, 24 Jul 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://orangon.github.io/tags/claude-code/index.xml" rel="self" type="application/rss+xml"/><item><title>接手老旧项目不用改公共gitignore：用git exclude静默忽略AI配置文件</title><link>https://orangon.github.io/posts/2026-07-24-git-exclude-ai-config/</link><pubDate>Fri, 24 Jul 2026 00:00:00 +0000</pubDate><guid>https://orangon.github.io/posts/2026-07-24-git-exclude-ai-config/</guid><description>&lt;h1 id="接手老旧项目不用改公共gitignore用git-exclude静默忽略ai配置文件"&gt;接手老旧项目不用改公共gitignore：用git exclude静默忽略AI配置文件
&lt;/h1&gt;&lt;p&gt;接手维护年代久远的历史项目时，很多人会借助 Coding Agent （例如Claude Code，Codex）生成 &lt;code&gt;CLAUDE.md&lt;/code&gt;、&lt;code&gt;AGENT.md&lt;/code&gt;，用来定制本地代码辅助规则。
这类文件只服务于我个人本地AI开发，不需要同步给团队、不能提交到远程仓库。但历史仓库的 &lt;code&gt;.gitignore&lt;/code&gt; 是团队统一维护的，随意新增规则会打乱原有规范，不适合修改；全局gitignore又会让所有项目都屏蔽这两个文件，灵活性太差。&lt;/p&gt;
&lt;p&gt;这时最佳方案：使用 &lt;strong&gt;git exclude&lt;/strong&gt;。&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="极简使用步骤"&gt;极简使用步骤
&lt;/h2&gt;&lt;ol&gt;
&lt;li&gt;进入项目根目录，创建对应目录（不存在则自动新建）&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mkdir -p .git/info
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ol start="2"&gt;
&lt;li&gt;编辑私有忽略文件 &lt;code&gt;.git/info/exclude&lt;/code&gt;，写入两行规则&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;CLAUDE.md
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;AGENT.md
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;保存后即时生效，无需额外Git命令。&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="核心优势"&gt;核心优势
&lt;/h2&gt;&lt;ol&gt;
&lt;li&gt;文件存放在 &lt;code&gt;.git&lt;/code&gt; 目录内，不会被Git追踪、推送远程，仅当前本地这份仓库生效；&lt;/li&gt;
&lt;li&gt;全程不动仓库里任何公开文件，&lt;code&gt;.gitignore&lt;/code&gt; 零改动，不会影响团队所有人；&lt;/li&gt;
&lt;li&gt;语法和gitignore完全一致，上手无学习成本。&lt;/li&gt;
&lt;/ol&gt;
&lt;hr&gt;
&lt;h2 id="简单选型对比"&gt;简单选型对比
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;项目&lt;code&gt;.gitignore&lt;/code&gt;&lt;/strong&gt;：改公共配置，全员生效，适合团队通用文件，此处不合适；&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;全局gitignore&lt;/strong&gt;：全电脑所有仓库统一屏蔽，会误伤其他需要保留CLAUDE.md的项目；&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;git exclude&lt;/strong&gt;：单仓库、个人私有屏蔽，完美适配本地AI配置。&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="结尾小结"&gt;结尾小结
&lt;/h2&gt;&lt;p&gt;所有仅自己使用、不方便改动团队忽略清单的本地文件，优先交给git exclude管理。&lt;/p&gt;</description></item></channel></rss>