Using multiple git user configs with credentials store (multiple github accounts)
Posted on 18 Feb, 2023
So, you have decided to have 2 separate accounts for work and personal. Here are steps to follow to use both git configurations simultaneously with same .git-credentials
.
Step 1: Separate Work/Personal directories
Create a work
and a personsal
directory in your Documents folder. Use these directories to separate your git directories.
Step 2: Separate git config for each account
Create
.gitconfig-personal
in thepersonal
dir.Create
.gitconfig-work
in thework
dir.
Step 3: Update global .gitconfig
to switch the profile based on directory
.gitconfig
to switch the profile based on directoryUpdate your global config using following command.
Add the following config.
Step 4: Register Access Tokens
Check your
.git-credentials
file & add github access tokens for each account.
That's it, the next time you pull/push/clone a private repo, git will automatically choose the correct token for each config.
PreviousParsing `git status` for tracked & untracked changesNextView a python function's history over-time with Git & FZF
Last updated