Teach you how to create a Repository on GitHub, push local warehouse projects to GitHub, create SSH keys, pull synchronization, and update certificates. Git usage tutorial using Git Bash

1. Create a new Repository on GitHub

 Create a new Repository named springcloud-config on GitHub:

Pay attention to the git URL address: https://github.com/pbjlovezjy/springcloud-config.git

Pay attention to the SSH address of git: [email protected]:pbjlovezjy/springcloud-config.git

2. Create a secret key

If the user name of GitHub is: pbjlovezjy 

Password: Panbinjie20021105

Step 1: Open Git bash and set username and email

git config --global user.name "Fill in your GitHub username"

git config --global user.name

git config --global user.email "Fill in your own GitHub registered email address"

git config --global user.email

Step 2: Enter the following code in Git Bash to create the key:

Generate a new SSH key pair: ssh-keygen -t rsa -b 4096 -C "[email protected]"

Start SSH agent: eval "$(ssh-agent -s)"

Add your private key to the SSH agent: ssh-add ~/.ssh/id_rsa

Copy the public key to the clipboard: clip < ~/.ssh/id_rsa.pub

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDDGxU+Ha4PAL5y6p2WUBR1Ll/pJKJA8yBF/4HOhFIukZKh2ZK/1o62N3lytHm5WKbjNfOSKyUBXgkb5+ZflB/HWI+Id3vP8uU/rk5VLuZIU18FhceK2nu5jAA897WGLEOpBJ2/ntQUQDUzeI5ak2y+zO9XQpXEpJ9n/HVxW444vVeIpc4VHKIkv/wf6LU+A5WG1OcAPWQHAyC/e1Ulkx8vUNqhk88WiXIoutAyDusXJGn+xLA52Pb0ojXTrfgDzfMaXZtgAmtAgWmhv51+tTjbiPNecN0AzdBjwQtAEcZ393HDsbf9Vwg3vPgqY9ivfMJ9UwM4czFKWIbHHk0SK5B+YH+rFjk5RnU9KE0DFcKHlwhUWwrSrjspeGQ4rzNwEAlirp8KjiHLkaxF6IV1ZvdZZ5AiOHR4tYR9i9I6n/QX7hQoCxO0YIPyTRZUtryZejW+ocFDZ0qKTo16/X4IeIQJvatTApdwe7LhG15+tvhMF5J3HtnF4e4J3GpYoZkUXk11Vvi3wsDnJHm0j7C2KwTaDlaRzv2otGv8QcpgaI9cN+9YOdhrFAVKL+XwhhYYPl66r+x4tln++9mfTc7m2QlhDDFLZ1eYxp+P4WQO4XcxPFxQt5jhXtyns3EuyLqY//6/OYONGmeV/BktRmLYeUjIUMWFwWjp1v8PlwL1zP99rQ== [email protected]

Step 3: Open GitHub and paste the key to complete the association:

Click the avatar in the upper right corner and select "Settings":

Select "SSH and GPG keys" in the left menu:

 

Click "New SSH key":

In the "Title" field, add a descriptive name for your key:

In the "Key" field, paste the public key you copied earlier:

Click "Add SSH key":

3. Clone the remote warehouse

Create a new 44 folder under the local disk D drive, and create SpringCloud2020 under the 44 folder

Start gitbash and then cd d:/44/SpringCloud2020

git clone [email protected]:zzyybs/springcloud-config.git

Here is an explanation of the git clone command, which is to clone things from the github remote repository to the local disk:

As in the above example, the source of the things to be obtained is: [email protected]:zzyybs/springcloud-config.git. This is a GitHub warehouse, which may be someone else's warehouse.

Things are stored at the local address /d/44/SpringCloud2020.

The following is the result after cloning:

4. Push the project from the local warehouse to GitHub

Right-click in the blank space under the spring-config folder and enter Git Bash

Then enter: git -c http.sslVerify=false push -u origin master

Then an interface will pop up, select sign in with your browser, select authorize the git system, and then enter the password:

 

You can submit the folder contents directly to the warehouse:

5. Synchronize the remote warehouse and submit the modified content

If we delete README.md in the local folder now, and we want to synchronize this modification to GitHub, how should we do it?

First we enter: git add . (note the dot at the end) to put all modified content into the buffer:

Then enter: git commit -m 'Fill in whatever you want'

You can synchronize the contents of local folders with GitHub.

Suppose we now modify the content on GitHub and add a README.mdd folder:

 

At this time, we do not have a README.md file locally. If we want to synchronize the remote warehouse and the local one:

Just enter: git -c http.sslVerify=false pull --rebase origin master  

The file was synchronized to the local machine by us:

Guess you like

Origin blog.csdn.net/RuanFun/article/details/134232906
Recommended