Setting up the environment of Ubuntu GIT and connecting GitHub (password free) through SSH

Time:2020-11-19

Git local environment configuration

1. Install GIT

sudo apt-get install git

2. Configure user information

$ git config --global user.name "Your Name"
$ git config --global user.email [email protected]

3. Initialize local warehouse configuration

git init

Connecting GitHub via SSH

1. Install SSH

sudo apt-get install ssh

First, SSH keygen confirms the storage location and file name of the key (default is. SSH / ID_ Then he will ask you to enter the key password twice and leave it blank. Therefore, generally select the default, all enter can be.

2. Create key file

Ssh-keygen - t RSA - C "your GitHub account email"

The default key file path is in~/.sshid_rsaIs a private key file,id_rsa.pubIs a public key file

3. Add the public key to GitHub

  1. takeid_rsa.pubCopy all the contents of the file
  2. Log in to GitHub and click New SSH key in the small avatar > setting > SSH and GPG keys in the upper right corner.

4. SSH test

ssh -T [email protected]

If the result is “… You’ve successfully authenticated, but GitHub does not provide shell access”, then it is successful.

5. Set up remote warehouse

git remote add origin [email protected]:Username/Repositories_Name.git

If the hand is wrong, you can use thegit remote remove originCommand to delete the remote warehouse.

6. Final test

  1. Create changes locally
  2. git add xxx
  3. git commit -m "xxxxxx"
  4. git push origin master

OK!