是否可以在多个文件夹的根级别拥有不同的.gitconfig
文件?我为工作存储库和个人存储库使用不同的电子邮件地址,并且很难始终记住在每个存储库上单独设置我的电子邮件。
我想要的是以下内容:
git/
├── work/
│ ├── .gitconfig (with user.email set to my work email)
│ ├── app1/
│ ├── app2/
└── home/
├── .gitconfig (with user.email set to my home email)
├── app3/
└── app4/
答案 0 :(得分:4)
除了" Can I specify multiple users for myself in .gitconfig?"中提到的答案外,我更喜欢另一种方法:
git config --global user.xxx
)强迫Git问我第一次提交时我是谁 This is possible with git 2.8+:
git config --global user.useConfigOnly true
使用别名设置正确的用户设置 在Windows上,我使用:
doskey gcu=git config user.name "My Name" ^&^& git config user.email my-email-for@work.com
doskey gcuvc=git config user.name "VonC" ^&^& git config user.email my-email-for@opensource.org
当Git问我自己是谁时,我会输入gcu
或gcuvc
,具体取决于Git远程仓库(工作或开源)的性质