Coder Social home page Coder Social logo

manage-multiple-git-accounts's Introduction

manage-multiple-git-accounts

Tutorial on managing multiple GitHub accounts

Why ?

Most of the developers have their personal git handles and also organization handle. This will help you to manage your personal, work and other git accounts.

Note: This is intended for unix users.

Steps

SSH keys

Assuming you've two accounts.

Create ssh key for each account.

cd ~/.ssh
ssh-keygen -t rsa -C "[email protected]"

Note: save it as id_rsa_personal when prompted

ssh-keygen -t rsa -C "[email protected]"

Note: save it as id_rsa_organization

You'll see following files in the ~/.ssh directory

  • id_rsa_personal
  • id_rsa_personal.pub
  • id_rsa_organization
  • id_rsa_organization.pub

Add keys to your github profile

pbcopy < ~/.ssh/id_rsa_personal.pub
  • Go to your personal github account
  • Click on settings
  • Select SSH keys & GPG keys
  • Add new SSH key
  • Paste the ssh key & give a name
  • Save the key

Note: Repeat it for your organization account.

Create configuration file to manage separate keys

Create config file in .ssh folder

touch ~/.ssh/config
# Personal
Host personal
 HostName github.com
 User git
 IdentityFile ~/.ssh/id_rsa_personal

# Organization
Host organization
 HostName github.com
 User git
 IdentityFile ~/.ssh/id_rsa_organization

Update stored identities

Clear current identities

ssh-add -D

Add new keys

ssh-add id_rsa_personal
ssh-add id_rsa_organization

Quick test ?

ssh-add -l
ssh -T personal
Hi Parthakodekart! You've successfully authenticated, but GitHub does not provide shell access.
ssh -T organization
Hi ParthaOrganization! You've successfully authenticated, but GitHub does not provide shell access.

Test Push

  • Create a repo in your personal github
  • Clone the repo
    git clone [email protected]:kodekart/personal.git
    
  • Add origin
    git remote add personal git@personal:kodekart/personal.git
    
  • Do some changes add something
    touch README.md
    
  • Push
    git add --all
    git commit -m "Added readme"
    git push personal master
    

Test Pull

git pull personal master

Ref: https://mherman.org/blog/2013/09/16/managing-multiple-github-accounts/

manage-multiple-git-accounts's People

Contributors

parthakodekart avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.