Integrating MacOS with multiple Github or Bitbucket accounts | DevsDay.ru

IT-блоги Integrating MacOS with multiple Github or Bitbucket accounts

dev.to 25 ноября 2021 г.


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 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.

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!

Источник: dev.to

Наш сайт является информационным посредником. Сообщить о нарушении авторских прав.

github git linux productivity