Code Monkey home page Code Monkey logo

oap_git_test's Introduction

Multiple Users and Multiple Projects Guide

By default, the git command uses the default SSH key pairs to communicate with GitHub.com. When you have different accounts and work on different projects, you need to do some special setup.

Create Specific SSH Keys for Your User

Generate a new SSH key specifically for this account:

ssh-keygen -t ed25519 -C "[email protected]" -f ~/.ssh/oap_key

Copy Your Public Key to Your GitHub Account:

  1. Copy your public SSH key to the clipboard (for Windows):

    cat ~/.ssh/oap_key.pub | clip

    For macOS:

    pbcopy < ~/.ssh/oap_key.pub

    For Linux (with xclip installed):

    xclip -sel clip < ~/.ssh/oap_key.pub
  2. Go to your GitHub account on github.com, login, and navigate:

    • Go to Settings under your account
    • Select SSH and GPG keys
    • Click New SSH key button, paste your key there

Test Your SSH Connection:

To check your setup is correct, you can run:

Add New SSH Config Beside the Default GitHub Config

Configure your SSH to recognize a new profile for GitHub using a specific key:

# Default GitHub 
Host github.com
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_rsa
  IdentitiesOnly yes

# New config for specific account
Host oap.github.com
  HostName github.com
  User git
  IdentityFile ~/.ssh/oap_key   
  IdentitiesOnly yes

Now your system can recognize oap.github.com as an alias for github.com.

Test Your SSH Connection Using the Alias

If everything is set up correctly, you'll see a message from GitHub stating that you've successfully authenticated, but GitHub does not provide shell access.

Clone Your Git Repo Using the Specific Host Alias

Clone your repository using the new SSH configuration:

git clone [email protected]:oap/oap_git_test.git

Modify the Existing Repository Remotes:

Open the .git/config file in a text editor and modify it as follows:

[remote "origin"]
    url = [email protected]:oap/oap_git_test.git
    fetch = +refs/heads/*:refs/remotes/origin/*

Test Your Setup

To ensure that your configuration works, run:

git fetch origin

oap_git_test's People

Contributors

oap avatar nicoatduenorth 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.