Want to be able to push code to work and personal projects without needing to switch
git users all the time?
The short guide bellow might be for you!
The most straight forward solution for me is to have separate work and personal folders with different
Here is a quick 3 step guide.
/home /personal-projects # Do this /personal-project1 /personal-project2 /work-projects # Do this /work-project1 /work-project2
/home /projects # Don't do that /personal-project1 /personal-project2 /work-project1 /work-project2
Inside each of these folders, add a individual
/home /personal-projects .gitconfig /personal-project1 /personal-project2 /work-projects .gitconfig /work-project1 /work-project2
.gitconfig file and add the relevant account for that folder:
[user] email = firstname.lastname@example.org name = Devimal Planet
[user] email = email@example.com name = Relaxed Devimal
Edit the global
.gitconfig, so it chooses the correct configuration on its own.
On Unix this file can be found at
~/.gitconfig. On Windows:
[user] # If local config does not exist, this user is used. name = Devimal Global email = firstname.lastname@example.org [includeIf "gitdir:~/work-projects/"] path = ~/work-projects/.gitconfig [includeIf "gitdir:~/personal-projects/"] path = ~/personal-projects/.gitconfig
Try this in a terminal window if for some reason you cannot find your
git config --list --show-origin
gitdir/i and full path with forward slash:
[includeIf "gitdir/i:C:/Users//Desktop/personal-projects/"] path = C:/Users//Desktop/personal-projects/.gitconfig
This will only affect future projects created with
git init. Previous projects will remain unchanged.