Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
November 25, 2021 10:27 pm GMT

Integrating MacOS with multiple Github or Bitbucket accounts

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.

Create a new SSH key

Register created SSH key to Github

Create SSH Config

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!

  • Create a config file $ cd ~/.ssh && touch config
  • Add your SSH configuration to config.

Here is the syntax that you need to understand.

# Host is the remote serverHost hostname1    SSH_OPTION value    SSH_OPTION value

In our case we want to use multiple Github/Bitbucket accounts, so it will be

# Your Github accountHost github.com-<jeffshomali>   User git   HostName github.com   IdentityFile ~/.ssh/<jeff_personal>     IdentitiesOnly yes

Just replace the <> with your information.

Clone your repository.

Go to your Github account and clone of the repository.

  • Open the repo in your code editor and make sure the Origin fetch and push urls are set with
  • $ git remote -v if not set that up with $ git remote add origin https://github.com/user/repo.git

Add your Github username and email to every repo locally.

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.

  • Open your Git config file with $ code .git/config or $ git config --local -e.
  • Add your username and email
[user]    name = your_github_username    email = [email protected]
  • Confirm your information has been saved and present in config file by $ git config --local -l and you should see your Github/Bitbucket user.name and user.email.

Done!


Original Link: https://dev.to/jeffshomali/integrating-macos-with-multiple-github-or-bitbucket-accounts-1an4

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To