# Git实用配置笔记

> 作者：James Zhu (<fatindeed@hotmail.com>)
>
> 创建日期：2018-09-12

## 正文

在用户主目录下，有一个 `.gitconfig` 文件。这个文件为当前用户的git默认配置。

```bash
$ cat ~/.gitconfig
[user]
    name = James
    email = fatindeed@hotmail.com
[filter "lfs"]
    clean = git-lfs clean -- %f
    smudge = git-lfs smudge -- %f
    process = git-lfs filter-process
    required = true
[core]
    excludesFile = ~/.git/.gitignore
    hooksPath = ~/.git/hooks
    mergeOptions = --no-edit
    quotePath = off
```

前两个没什么特别说的，主要说一下 `core` 下面3个配置的作用：

1. **core.excludesFile**

   配置全局排除文件，具体gitignore相关资料请[查阅此文](https://github.com/fatindeed/knowledge-base/tree/eb073c4b83eb7dd0eb215e43c27730391f1564a0/Git/gitingore.md)。
2. **core.hooksPath**

   默认hooksPath为 `$GIT_DIR/hooks` ，即每个Git库下的hooks目录。将它配置为绝对路径后，即所有Git库使用同一个hooks目录。
3. **core.mergeOptions**

   在执行 `git merge` 等命令时，会唤醒编辑器，让你输入合并提交消息。配置该选项后，不会出现编辑器界面，直接提交。
4. **core.quotePath**

   在执行 `git status` 等命令时，对于中文文件名会进行转移。配置该选项后，即会直接显示中文文件名。

## 参考资料

* [git-config Documentation](https://git-scm.com/docs/git-config)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sjp.gitbook.io/knowledge-base/kai-fa/git/gitconfig.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
