Develop Paper
  • Program
  • Server
  • Development Tool
  • Blockchain
  • Database
  • Artificial Intelligence
Position: Home > Server > Content

How to manage multiple GitHub accounts on one machine

Time:2020-12-3

scene

On a computer, there are two repositories that belong to two different GitHub accounts.

step

Configure GitHub’s git account for repository

Use the terminal to enter the repository a directory and configure the GIT account

$ git config user.name "user_a"
$ git config user.email "[email protected]"

Use the terminal to enter the repository B directory and configure the GIT account

$ git config user.name "user_b"
$ git config user.email "[email protected]"

Generating SSH keys for different GitHub users

For user_ A generates an SSH key named user_ A_ Id_ RSA

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

The same operation, for user_ B generates an SSH key named user_ B_ Id_ RSA

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

Configure SSH matching of multiple accounts

In the. SSH directory, create a new config file and configure the key of multi-user

host user_a_github.com
    Hostname github.com 
    User git 
    IdentityFile ~/.ssh/user_a_id_rsa  

host user_b_github.com
    Hostname github.com 
    User git 
    IdentityFile ~/.ssh/user_b_id_rsa

Add a new private key to the SSH agent cache

$ eval "$(ssh-agent -s)"
$ ssh-add ~/.ssh/user_a_id_rsa
$ ssh-add ~/.ssh/user_b_id_rsa

Modify the push address of the repository

For the URL field value of. Git / config in the repository[email protected]Modification.

Modify the push address of repository a:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = true
[remote "origin"]
    url = [email protected]_a_github.com:*********/***********.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[user]
    name = user_a
    email = [email protected]

Modify the push address of repository a:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = true
[remote "origin"]
    url = [email protected]_b_github.com.com:******/******.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[user]
    name = user_b
    email = [email protected]

That’s it.

Some orders

#Check current user
ssh -vT [email protected]
#Check the original key
ssh-add -l
#Add key
#Delete key
ssh-add -d /Users/****/.ssh/id_rsa
#View git config configuration
git config --list

git

This work adoptsCC agreementThe author and the link to this article must be indicated in the reprint

Write the code.Change the world.

Tags: Account number, address, Catalog, secret key, terminal

Recommended Today

Interviewer: young man, what do you think of the principle of distributed system

1 Concept 1.1 model 1.2 copies 1.3 indicators for measuring distributed systems 2. Principle of distributed system 2.1 data distribution 2.2 basic copy agreement 2.3 lease mechanism 2.4 quorum mechanism 2.5 log technology 2.6 two phase submission protocol 2.7 MVCC 2.8 Paxos protocol 2.9 CAP 1 Concept 1.1 model node In a specific project, a […]

  • Notes on docker deep dive (1)
  • 5000 + words hard core dry goods! Redis distributed cluster deployment
  • Apache Tajo: a distributed data warehouse running on yarn supporting SQL
  • Discussion on RSA and how to crack HTTPS
  • Several ways to input similar commands repeatedly
  • Build from scratch Node.js Enterprise web server (11): timed tasks
  • Linux uses iftop to monitor the traffic of network card in real time
  • Tencent SNG background technology director: hundreds of millions of background architecture
  • U disk installation of ghost win8 system graphic explanation — win10 Professional Edition
  • Linux set default editor (qbit)
Pre: Primary analog circuit: 5-3 transformer coupled class a power amplifier
Next: MySQL has the most complete learning resources in history (updated from time to time every day)

    Tags

    address algorithm android array assembly attribute Browser c Catalog Character string Client code command configuration file css data Database data base Edition element Example file function golang html html5 ios java javascript linux method mysql node node.js object page parameter php Plug-in unit project python Route source code The server user

    Recent Posts

    • Interviewer: young man, what do you think of the principle of distributed system
    • What can we learn from HelloWorld
    • Centos7 reset root password (detailed version)
    • Windows 10 uses screen keyboard
    • Interpretation of laravel kernel — HTTP kernel

    Recent Comments

    • Li VST on Answer for Didi travel app home page selection address can be pushed to the top of the effect how to do?
    • Li VST on Answer for Didi travel app home page selection address can be pushed to the top of the effect how to do?
    • Li VST on Answer for Didi travel app home page selection address can be pushed to the top of the effect how to do?
    • Li VST on Didi travel app home page selection address can be pushed to the top of the effect how to do?
    • Healy on Answer for Is the main thread of browser JS engine thread?

    Categories

    • .NET Core
    • Agile Development
    • Android
    • Apple MAC
    • Architecture Design
    • Artificial Intelligence
    • ASP.NET
    • Blockchain
    • C
    • C#
    • C++
    • Database
    • Development Tool
    • Embedded
    • Erlang
    • Freshman
    • Golang
    • HTML/CSS
    • HTML5
    • Information Security
    • IOS
    • Java
    • JavaScript
    • JSP
    • Linux
    • MongoDB
    • MsSql
    • MySql
    • OOP
    • oracle
    • Other DB
    • Other Technology
    • Perl
    • PHP
    • Program
    • Python
    • Redis
    • Regular Expression
    • Ruby
    • Rust
    • SAP
    • Server
    • VBS
    • VUE
    • WEB Front End
    • Windows
    • XML/XSLT
  • java
  • php
  • python
  • linux
  • windows
  • android
  • ios
  • mysql
  • html
  • .net
  • github
  • node.js

Copyright © 2020 Develop Paper All Rights Reserved   

  Sitemap    About DevelopPaper    Privacy Policy    Contact Us