Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

根据目录使用不同的git config #50

Open
varHarrie opened this issue Feb 21, 2023 · 0 comments
Open

根据目录使用不同的git config #50

varHarrie opened this issue Feb 21, 2023 · 0 comments
Labels
Milestone

Comments

@varHarrie
Copy link
Owner

通过git(>2.13)的include配置,可以合并外部的配置到~/.gitconfig,而includeIf可以添加条件,具体示例如下:

# .gitconfig
[user]
    name = varHarrie
    email = varharrie@gmail.com
[includeIf "gitdir:~/company/"]
    path = .gitconfig-company
# .gitconfig-company
[user]
    name = My Name
    email = my-name@company.com

其中,includeIf支持以下条件参数:

  • gitdir:根据目录
  • gitdir/i:根据目录(忽略大小写)
  • onbranch:根据分支名称

具体配置,参考[官方文档](https://git-scm.com/docs/git-config#_includes)。

@varHarrie varHarrie added the Git label Feb 21, 2023
@varHarrie varHarrie added this to the Snippets milestone Feb 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant