So i have a mac given to me by organistaion for company work. My mac os verison is macOS Monterey version 12.6 Now i have one github account setup here for my company (2FA enabled and using HTTPS with Personal access token) git version 2.37.0 (Apple Git-136) Adding .git/config file output here (local file inside repo path).
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = https://github.com/<<company_name>>/<<repo_name>>.git
fetch = +refs/heads/*:refs/remotes/origin/*`
Adding global config file output (~/.gitconfig)
[credential]
helper = osxkeychain
[url "https://company_username@github.com"]
and inside keychain there are two enteries for github.com
Internet password
application password
Both having my personal access token for the company id. This all works fine as PAT is saved in keychain.
Now i have created a new github account under my name (for personal projects) and following is the local .git/config file output there.
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[user]
name = <<personal_username>>
email = <<personal_email_id>>
[remote "origin"]
url = https://<<PAT>>@github.com/<<personal_username>>/<<repo_name>>.git
fetch = +refs/heads/*:refs/remotes/origin/*
[credential]
helper =
i have added PAT here so that it does not copies the one from keychain (as i tried different solutions online)
However, when i try to clone or push in this repo it gives error.
remote: Repository not found.
fatal: repository 'https://github.com/<<personal_user>>/<<repo>>.git/' not found
what i understand is it is taking PAT from keychain and that one is for my company's PAT so giving this error. However i might be wrong. Adding output for my .netrc
machine github.com login <<company_username>> password <<company_PAT>>
I am able to think of two ways to do this
- enable keychain for only company's repo and not for personal repo so that i can add PAT personal each time
- Add different PAT for different account in keychain
However i am not able to come up with any solution after trying everything online. Again, i am using HTTPS (most of solution online are .SSH) Thank you in advance.