Assume you want to use your personal Github account on your work laptop, and wanted to commit to your personal account without breaking your work repository configuration. In this tutorial I will show you how to easily manage multiple Github/Bitbucket accounts on MacOS without conflict each other.
To achieve our goal we need to tell Github/Bitbucket Git's engine that we have multiple account in one computer.
So bare with me to achieve our goal.
$ cd ~/.ssh
ssh-keygen -t rsa -b 4096 -C <[email protected]?More on Github
To connection to multiple remote server through the SSH we can use the SSH
config file. I'm not going to explain what is
config file in this post, but if you like to learn more about that here "Using the SSH Config File" is a cool article that I found for you. Ok less talk do more!
$ cd ~/.ssh && touch config
Here is the syntax that you need to understand.
# Host is the remote server Host hostname1 SSH_OPTION value SSH_OPTION value
In our case we want to use multiple Github/Bitbucket accounts, so it will be
# Your Github account Host github.com-<jeffshomali> User git HostName github.com IdentityFile ~/.ssh/<jeff_personal> IdentitiesOnly yes
Just replace the
<> with your information.
Go to your Github account and clone of the repository.
pushurls are set with
$ git remote -vif not set that up with
$ git remote add origin https://github.com/user/repo.git
To prevent the conflict between your personal repo and your work repos you need to add your information to each repo by add the username and email to local repo.
$ code .git/configor
$ git config --local -e.
[user] name = your_github_username email = [email protected]
$ git config --local -land you should see your Github/Bitbucket
Источник: dev.togithub git linux productivity