<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>版本控制 on 代码学习站</title>
        <link>https://a6233.com/tags/%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6/</link>
        <description>Recent content in 版本控制 on 代码学习站</description>
        <generator>Hugo -- gohugo.io</generator>
        <language>zh-cn</language>
        <lastBuildDate>Mon, 14 Oct 2024 00:00:00 +0000</lastBuildDate><atom:link href="https://a6233.com/tags/%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6/index.xml" rel="self" type="application/rss+xml" /><item>
        <title>Git 取消跟踪文件</title>
        <link>https://a6233.com/posts/git-%E5%8F%96%E6%B6%88%E8%B7%9F%E8%B8%AA%E6%96%87%E4%BB%B6/</link>
        <pubDate>Mon, 14 Oct 2024 00:00:00 +0000</pubDate>
        
        <guid>https://a6233.com/posts/git-%E5%8F%96%E6%B6%88%E8%B7%9F%E8%B8%AA%E6%96%87%E4%BB%B6/</guid>
        <description>&lt;p&gt;要从 Git 中移除已跟踪的文件，同时保持这些文件在本地存在（不删除本地文件），你可以按照以下步骤操作：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;更新 &lt;code&gt;.gitignore&lt;/code&gt; 文件&lt;/strong&gt;：确保你已经正确配置了你想忽略的文件或目录。&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;移除文件的追踪&lt;/strong&gt;：使用 &lt;code&gt;git rm --cached&lt;/code&gt; 来移除已追踪的文件。&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;git rm -r --cached &amp;lt;file_or_directory&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;例如，如果你想移除 &lt;code&gt;.log&lt;/code&gt; 文件的追踪：&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;git rm -r --cached *.log
&lt;/code&gt;&lt;/pre&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;提交更改&lt;/strong&gt;：移除追踪后需要提交这些更改。&lt;/li&gt;
&lt;/ul&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;git commit -m &amp;#34;移除已追踪的文件，更新 .gitignore&amp;#34;
&lt;/code&gt;&lt;/pre&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;推送更改&lt;/strong&gt;（如果有远程仓库）：&lt;/li&gt;
&lt;/ul&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;git push origin &amp;lt;branch_name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;执行以上步骤后，Git 将停止追踪 &lt;code&gt;.gitignore&lt;/code&gt; 中定义的文件或目录，但这些文件仍然会保留在你的本地文件系统中。&lt;/p&gt;
</description>
        </item>
        
    </channel>
</rss>
