git 同一系统内不同项目的多个用户名
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9063176/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
git multiple user names for the different projects within the same system
提问by whatf
I have a different git repository for my office and a different git repo for my hobby projects.
我的办公室有一个不同的 git 存储库,我的爱好项目有一个不同的 git 存储库。
When I do git config --global user.name
the user name changes globally and this creates a confusion
of committing to a repo with user name.
当我git config --global user.name
在全局范围内更改用户名时,这会造成将用户名提交到存储库的混淆。
Hence the question is how can i have the same username across all my hobby projects and the same username across the office projects. I use the same machine to work on both the places.
因此,问题是我如何在所有爱好项目中使用相同的用户名,并在办公室项目中使用相同的用户名。我使用同一台机器在这两个地方工作。
回答by mikej
Just use --local
instead of --global
. In fact, local is the default so you can just do
只需使用--local
代替--global
. 事实上,本地是默认的,所以你可以这样做
git config user.email [email protected]
git config user.name "whatf hobbyist"
in one repo, and
在一个回购中,和
git config user.email [email protected]
git config user.name "whatf at work"
in another repo
在另一个回购
The values will then be stored in in the .git/config
for that repo rather than your global configuration file.
然后这些值将存储在该存储.git/config
库中而不是您的全局配置文件中。
回答by Bombe
Omit the --global
from your call to git config
:
--global
从您的呼叫中省略git config
:
git config user.name "A. U. Thor"
This will set the property in the current repository.
这将在当前存储库中设置属性。