Git 多项目配置
Git 多项目配置
通常,安装 Git 后会设置一个全局的用户名/邮箱,Git 的全局配置保存在 ~/.gitconfig。
有时会在公司的电脑上做一些开源项目,但 git commit 提交的是公司的用户名/邮箱。
那如何设置为自己的用户名?可以用 git config user.name "your name" 为项目单独设置,也可以用 includeIf
includeIf
Git v2.13 提供 includeIf 条件配置,可以指定某个目录所使用的 gitconfig
- 修改
.gitconfig文件
# ~/.gitconfig
[includeIf "gitdir:~/work/"]
path = .gitconfig-work
[includeIf "gitdir:~/me/"]
path = .gitconfig-me
- 为公司项目目录创建
.gitconfig-work文件
# ~/.gitconfig-work
[user]
name = my work
email = work@company.net
- 为个人项目目录创建
.gitconfig-me文件
# ~/.gitconfig-me
[user]
name = my github
email = me@gmail.net
开源项目放到 ~/me/ 下,工作项目放到 ~/work/,这样就不用每个项目单独设置了
参考
本博客(marsk6)所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
本文来自博客园,作者:marsk68,转载请注明原文链接:https://www.cnblogs.com/marsk6/p/15111916.html

浙公网安备 33010602011771号