> For the complete documentation index, see [llms.txt](https://sjp.gitbook.io/knowledge-base/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sjp.gitbook.io/knowledge-base/kai-fa/git/gitconfig.md).

# 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)
