Create SSH, Key, and some commonly used Git terminal instructions

Objective

FYI

Create SSH, Key, and some commonly used Git terminal instructions
Git

Create SSH Key

1. in the user home directory, see if there is a.Ssh directory. Methods: Command view hidden files you can see if there is 2. by LS -ah in the terminal, and then look at the directory there is no id_rsa and id_rsa.pub these two documents, if have, that computer has SSH Key. 3. if you do not have the.Ssh directory, enter the $ssh-keygen -t RSA -C “your mailbox address” 4. at the terminal, and continue to complete the creation according to the prompt of the terminal. 5. after the completion of the.Ssh directory can be found in the user’s home directory, which has id_rsa and id_rsa.pub two files, the two is the SSH Key of id_rsa is the key, private key, public key is id_rsa.pub. (Figure 1)

Create SSH, Key, and some commonly used Git terminal instructions
diagram 1 public key private key

Access your GitHub with SSH Key

1. login GitHub, enter “settings””. (Figure 2)

Create SSH, Key, and some commonly used Git terminal instructions,
, figure 2

2. click SSH and GPG keys in the sidebar. (Figure 3)

Create SSH, Key, and some commonly used Git terminal instructions,
, figure 3

3. click on the New SSH Key. (Figure 4)

Create SSH, Key, and some commonly used Git terminal instructions,
, figure 4

4. fill in your computer’s public key (Figure 5), and then click Add SSH key below to complete the add

Create SSH, Key, and some commonly used Git terminal instructions,
, figure 5

To clone your own project on GitHub locally, you can push it to GitHub after modification

1. has been configured with SSH key.
2. is trying to clone a repository. You must first know the address of the warehouse (Figure 6) 3., and then clone it using the GIT clone command. $git clone your git library address

Create SSH, Key, and some commonly used Git terminal instructions,
, Figure 6

Commonly used git terminal instructions

$git add readme.txt to add the file to the warehouse commit -m $git “wrote a readme file” submit to the warehouse push origin master $git $Git pushed to the distal status view state $git reflog $git reset command history – hard 5a1902c to a branch view submitted $git $git branch name to create a branch checkout name branch $git $git merge name with switching branch of a branch to the branch -d name branch $git $git stash delete branch when the hand work is not completed, the work site git stash, and then to repair bug, after repair, GIT stash pop again, back to the job site


GitHub address: https://github.com/remember17