Remember to specify different path to both of that keys!
Create a ~/.ssh/config file with the content similar to:
Create folders for your private and work projects, eg:
Open ~/.gitconfig file and make sure it looks somehow similar to:
Create a new config file (eg. ~/.gitconfig.work) for each github account with a content such as:
Let's copy the ./add.sh file into all the ~/priv/ and ~/work/ folders. Also in each of these locations create the .env file containing a single environmental variable, like so:
Simply run the script:
Now if you commit things from, say private folder, the private ssh/git config will be used, likewise the work folder.
Partly taken from here