2

I have logged in my Github (using Github Desktop) and Gitlab account in my laptop and it has different name and email. When I commit my code to my Gitlab repo, the account that make a commit is Github account. And when I check using git config --list it shows my Github account.

How to seperate my Github and Gitlab account so it will use correct account when do some commit etc. Thank you

1 Answers1

1

In your GitLab repository folder, set the proper name/email

git config user.name "your Name"
git config user.email your@email.com

That way, you will create commits using the local setting to that specific repository.


Another approach is to put your GitLab repositories in a gitlab folder.
That way, you can include in your global config ~/.gitconfig a config dedicated to GitLab depending on the path:

[includeIf "gitdir:~/gitlab/"]
  path = .gitconfig-gitlab

That means you don't have to set your user/email for each individual GitLab repositories you are cloning.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250