I am using Github
for the personal repositories and GitLab
for the companies team repositories.
Thanks to [1] and [2], I was able to separate personal repositories with the work repositories (in the context of git account info) like below gitconfig
script.
However, I still couldn't separate the git credentials
. Thus, I have to write ids and passwords every time they are required. Can someone help me separating the git credentials by the working directory for two different git accounts like the below config files?
~/.gitconfig
[user]
email = personal@gmail.com
name = My Name
[includeIf "gitdir:~/repositories/work/"]
path = ~/repositories/work/.gitconfig
~/repositories/work/.gitconfig
[user]
email = MyName@company.com
name = My Name
p.s. My setting is git 2.25.x and Ubuntu 20.04.