[getting started with git 5] git remote warehouse – GitHub common operation process 1_ to configure



  • The local warehouse and the remote warehouse are completely separated
  • The code is stored in the cloud GitHub
  • SSH key authentication scenarios: we can avoid repeated password input, improve development efficiency; access remote services
  • If the SSH key private key (i.e. the ID in the. SSH folder_ RSA file) is obtained by a third party, then he can operate git warehouse with your identity, which is as serious as password theft

GitHub operation flow of GIT remote warehouse

0. Premise

  1. There is an account on GitHub
  2. Git warehouse on computer
  • Upload code: private key encryption
  • GitHub decrypts with the public key left by the account

1. Generate SSH key

Step 1 run the command

ssh-keygen -t rsa -b 4096 -C "[email protected]"
Copy code

Step 2 enter three times until there is no prompt; then

cat ~/.ssh/id_rsa_pub
Copy code

Step 3 copy the content, go to GitHub Home > Settings page > SSH key… Fill in the title to indicate which computer is OK, fill in the public key


GitHub_ SSH key help document

2. Test whether the configuration is successful

Step 1 run the command

ssh -T [email protected]
Copy code

Step 2 confirm the public key given by GitHub

Do not enter, enter yes

Step 3

When you see hi XXX! You’ve successfully authenticated… It means that the addition is successful

3. Attention

  • GitHub, don’t use the HTTPS protocol. It’s inconvenient to enter the password every time
  • Using SSH key
  • Computer – private key GitHub account – public key
  • The upload code is encrypted with the private key, and the GitHub is decrypted with the public key
  • If the hand cheap has generated an HTTPS link, it is not convenient to usegit remote add ...It’s over

You can set:

git remote set-url origin [email protected]:yourName/***.git
Copy code

To modify the previous origin URL, isn’t it a chicken thief

4. View the generated SSH key file directory and back it up

cd ~/.ssh
Copy code
$ ls -al ~/.ssh
# Lists the files in your .ssh directory, if they exist
Copy code
cp id_rsa id_rsa_bk
cp id_rsa.pub id_rsa_bk.pub
Copy code


1. Code you need to copy

SSH keygen - t RSA - B 4096 - C your email
cat ~/.ssh/id_ rsa.pub  #Get public key content
ssh -T [email protected]
git remote add origin [email protected]
git push -u origin master
Copy code

2. Advanced operation

touch ~/.bashrc
echo 'alias ga="git add"'>> ~/.bashrc
echo 'alias gc="git commit -v"'>> ~/.bashrc
echo 'alias gl="git pull"'>> ~/.bashrc
echo 'alias gp="git push"'>> ~/.bashrc
echo 'alias gco="git checkout"'>> ~/.bashrc
echo 'alias gst="git status -sb"'>> ~/.bashrc
Copy code

3. Code ~ /. Bashrc is added at the end of the file

alias glog="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit -- | less"
Copy code

My configuration:

alias Glg="git log --color --graph --date=relative --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
Copy code

put questions to

Is there a combo technology that can realize one click GA + GV “XXX” + GL + GP + GST?

How about adding SSH key repeatedly?

The key you added before will be invalid

·To be continued·

Reference article

Git command used frequently: it’s not an introductory document. The official document is definitely more comprehensive than mine. Here is the output combined with the actual business scenario.

If you see “access denied”: it means that access is denied, then you need to use HTTPS instead of SSH to access.

Problems in adding SSH key to GitHub

Tell you the common use scenarios and configuration of SSH

Git: how to manage multiple local SSH keys

SSH keys automatic management tool

In Coding.net Add public key

Checking for existing SSH keys

Generating a new SSH key and adding it to the ssh-agent

Related articles

Git remote warehouse.pdf

  • By Joel
  • Article link:
  • Copyright notice
  • Non free reprint – non commercial – non derivative – keep signature
  • A brief introduction to river digging

Recommended Today

Implementation skills of three level linkage pull down menu with JSP + DWR

I see some examples on the Internet. For a simple three-level linkage, struts, hibernate and other frameworks are added. This Ajax linkage has nothing to do with these frameworks. Why is a small demo so big. Today I did an example of DWR + JSP.web.xml: Copy codeThe code is as follows : <?xml version=”1.0″ encoding=”UTF-8″?> […]