Trying to work on my both my actual \"work\" repos, and my personal repos on git hub, from my computer.
The work account was set up first, and everything works flawl
.gitconfig
using a personal access tokenIf you do not want to modify your host file, use SSH keys, or setup a .gitconfig
for each repo, then you may use a personal .gitconfig
that you basically include from the root level config. Given an OSX directory structure like
# root level git config
~/.gitconfig
# your personal repos under some folder like
../personal/
../home/
~/Dropbox/
Add a .gitconfig
in your personal folder, such as ~/Dropbox/.gitconfig
[user]
email = first.last@home.com
name = First Last
[credential]
username = PersonalGithubUsername
helper = osxkeychain
In your root level .gitconfig
add an includeIf section to source your personal config whenever you are in your personal directory. Any settings there will override the root config as long as the includeIf
comes after the settings you want to override.
[user]
email = first.last@work.com
name = "First Last"
[credential]
helper = osxkeychain
[includeIf "gitdir:~/Dropbox/**"]
path = ~/Dropbox/.gitconfig
Try pushing to your personal repo or pulling from your private repo
git push
# prompts for password
When prompted enter either your personal password or, better yet, your personal access token that you have created in your account developer settings. Enter that token as your password.
Assuming you are already using git-credential-osxkeychain, your personal credentials should be stored in your keychain, so two github
entries will show up, but with different accounts.