Download Git installation
It can be installed by default, and then the menu bar opens git bash

First installation configuration

 #Configure mailbox with the same account name git config --global user.name “Your_github-Username” git config --global user.email “Your_github-email” #View user name mailbox git config user.name git config user.email #You can also view user mailboxes directly vim ~/.gitconfig : q Exit

Create SSH Key
Since the transmission between the local Git warehouse and the Github warehouse is encrypted through SSH, the following settings need to be set when connecting

First, check whether there is an. ssh directory in the user directory of disk C Hidden (C: Users user name)
If so, see if. ssh has Private key id_rsa and public key id_rsa.pub If there are two files, skip to the next step. If not, create them with the following command

 ssh-keygen -t rsa -C "your_github-email"

Go straight back a few times

Github Set SSH Key
Log in to Github New SSH key

title content
Title For example: Git
Key Generated: id_rsa.pub

Create empty warehouse (for uploading)
https://github.com/new

Other commands

git rm -r --cached .
Delete all files in the cache (note this. If there are spaces, you can cancel a file by changing the file name to.)

Git upload

The remote warehouse is empty

(New warehouse, no README. md)

1. cd to the directory to be uploaded (local warehouse)
For example, test folder, pwd can view the current location

2. Initialize the local warehouse

 git init

A. git folder will be created under the current test directory
It means to turn this folder into a Git manageable repository, which is a local repository used by Git to track and manage version libraries

3. Associate remote warehouse

 Git remote add origin HTTPS address of github warehouse

4. Add files to the cache

 git add .        // All contents in the current directory Git add user//Specify a file or folder Git status//View the cache file

(Note that this "." has spaces. "." means that all files under this test folder are submitted. You can also submit the specified file through the git add file name

5. Submission Instructions

 git commit -m 'first commit'

-The quotation marks after m are the comments submitted this time, and errors will be reported if they are not filled in

6. Upload

branch

 Git branch xxx//Create a branch Git branch - a//View branches Git checkout xxx//Switch branches
 git push -u origin master

The remote warehouse is empty, so the - u parameter should be added to push the cached file to the master branch of github warehouse

The remote warehouse is not empty

(Old warehouses, including those without records)

1. Clone the remote warehouse (download it)

 Git clone warehouse address

2. CD to cloned warehouse
➽ The cloned warehouse contains Git folder, no need to initialize and associate remote warehouse address with git init

3. Add files to the cache

 git add .        // All contents in the current directory Git add user//Specify a file or folder Git status//View the cache file

4. Submission Instructions

 git commit -m 'first commit'

5. Upload

 git push origin master

Delete warehouse file

Local and remote deletion

 Git clone warehouse address //Negligible Git rm file//The local file will be deleted Git rm - r folder//local will be deleted git rm -rf .               // All local items will be deleted Git commit - m 'Delete a file' git push origin master

The corresponding local file will also be deleted. If you do not want to delete the local file but only delete the corresponding part in the cache, add --cached

Delete remote warehouse only

 Git clone warehouse address //Negligible Git rm -- cached file//The local file will not be deleted Git rm - r -- cached folder//Local will not be deleted git rm -rf --cached .            // All local items will not be deleted Git commit - m 'Delete a file' git push origin master

End