<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Git Config on GitFAQ中文网</title><link>http://www.gitfaq.cn/tags/git-config/</link><description>Recent content in Git Config on GitFAQ中文网</description><generator>Hugo</generator><language>zh</language><copyright>[black8](https://0x8.net/)</copyright><lastBuildDate>Mon, 26 Oct 2026 17:16:02 +0800</lastBuildDate><atom:link href="http://www.gitfaq.cn/tags/git-config/index.xml" rel="self" type="application/rss+xml"/><item><title>初次使用 Git 的一些配置</title><link>http://www.gitfaq.cn/posts/Some_configurations_for_the_first_time_using_Git/</link><pubDate>Thu, 25 Jul 2024 16:46:12 +0800</pubDate><guid>http://www.gitfaq.cn/posts/Some_configurations_for_the_first_time_using_Git/</guid><description>&lt;p&gt;安装完Git，你会想要做几件事来定制你的 Git 环境。 每台计算机上只需要配置一次，程序升级时会保留配置信息。 你可以在任何时候再次通过运行命令来修改它们。&lt;/p&gt;&#10;&lt;h3 id="git配置管理"&gt;git配置管理&lt;a class="anchor" href="#git%e9%85%8d%e7%bd%ae%e7%ae%a1%e7%90%86" aria-label="Link"&gt;&lt;/a&gt;&lt;/h3&gt;&#10;&lt;p&gt;Git 自带一个 &lt;code&gt;git config&lt;/code&gt; 的工具来帮助设置控制 Git 外观和行为的配置变量。 这些变量存储在三个不同的位置：&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;/etc/gitconfig&lt;/code&gt; 文件: 包含系统上所有用户及他们仓库的通用配置。 如果在执行 &lt;code&gt;git config&lt;/code&gt; 时带上 &lt;code&gt;--system&lt;/code&gt; 选项，那么它就会读写该文件中的配置变量。 （需要管理员或超级用户权限）&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;&lt;code&gt;~/.gitconfig&lt;/code&gt; 或 &lt;code&gt;~/.config/git/config&lt;/code&gt; 文件：只针对当前用户。 你可以传递 &lt;code&gt;--global&lt;/code&gt; 选项让 Git 读写此文件，这会对你系统上 所有 的仓库生效。&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;当前使用仓库的 Git 目录中的 &lt;code&gt;config&lt;/code&gt; 文件（即 &lt;code&gt;.git/config&lt;/code&gt;）：针对当前仓库。 你可以传递 &lt;code&gt;--local&lt;/code&gt; 选项让 Git 强制读写此文件，虽然默认情况下用的就是它。 （需要进入某个 Git 仓库中才能让该选项生效。）&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;每一个级别会覆盖上一级别的配置，所以 &lt;code&gt;.git/config&lt;/code&gt; 的配置变量会覆盖 &lt;code&gt;/etc/gitconfig&lt;/code&gt; 中的配置变量。&lt;/p&gt;&#10;&lt;p&gt;在 Windows 系统中，Git 会查找 &lt;code&gt;$HOME&lt;/code&gt; 目录下（一般情况下是 &lt;strong&gt;C:\Users$USER&lt;/strong&gt; ）的 &lt;code&gt;.gitconfig&lt;/code&gt; 文件。 Git 同样也会寻找 &lt;code&gt;/etc/gitconfig&lt;/code&gt; 文件，但只限于 MSys 的根目录下，即安装 Git 时所选的目标位置。 如果你在 Windows 上使用 Git 2.x 以后的版本，那么还有一个系统级的配置文件，Windows XP 上在 &lt;code&gt;C:\Documents and Settings\All Users\Application Data\Git\config&lt;/code&gt; ，Windows Vista 及其以后的版本在 &lt;code&gt;C:\ProgramData\Git\config&lt;/code&gt; 。此文件只能以管理员权限通过 &lt;code&gt;git config -f &amp;lt;file&amp;gt;&lt;/code&gt; 来修改。&lt;/p&gt;</description></item></channel></rss>