How can I have multiple git accounts on a single d

2019-08-02 13:22发布

I am trying to work simultaneously on more than one (two or three) GitLab (or even GitHub) projects on a single development machine. Because upon configuration the IDEs and the git service has the data of my primary user when I try to checkout or clone another project with a different username / password the system says either project is not found or I do not have permissions to do that.

How can I configure and use more than one git user on a single development machine?

3条回答
爷、活的狠高调
2楼-- · 2019-08-02 13:49

By default, git is using a system-wide configuration file or the one stored at top of your home directory.

But you can also set a file .git/config inside each repository, either by editing manually or using git config. Inside, you may specify the following sections :

[user]
    name = Your name
    email = yourownemail@yourprovider.com

…

[credential "<your_project_hoster_url>"]
    username = <username to log in with>

You can check git config in general or git credentials in particular for more information about it.

查看更多
我只想做你的唯一
3楼-- · 2019-08-02 13:56

You can configure your user details per repository.

git config user.name 'Your Name'
git config user.email 'name@example.com'

GitHub can be configured to recognise several ssh keys assigned to email addresses and send email messages to the corresponding ones when needed.

查看更多
何必那么认真
4楼-- · 2019-08-02 13:58

You can store your credentials in each project using.

git config credential.helper store
git push origin HEAD
write user and password

Go to the project folder and type the git commands.

查看更多
登录 后发表回答