1. Register a GitHub account and create a warehouse
2. Download and install Git on the official website
$ https://git-scm.com/download/
2.1 In the user's home directory, check to see if there is a .ssh directory. If so, check to see if there are two files, id_rsa and id_rsa.pub, in this directory. If there are, you can skip to the next step.
If not, open Shell (open GitBash under Windows), and right-click to find option
$Git bash here
Create SSH Key, the password can be set directly without entering
$ ssh-keygen -t rsa -C "[email protected]"
If all goes well, you can find the .ssh directory in the user's home directory. There are two files, id_rsa and id_rsa.pub. These two are the key pair of the SSH Key. id_rsa is the private key, which cannot be leaked. id_rsa.pub is the public key and can be safely told to anyone. Open id_rsa.pub (C:\Users\Administrator\.ssh) with Notepad and get the ssh key public key. Add ssh key for Github account. Log in to Github, expand the small triangle of your profile picture, click settings, then open the SSH keys menu, click Add SSH key to add a new key, which is the content in the id_rsa.pub file, just copy and paste all of them, and fill in the title.
- clone the repository
If it is a brand new project without any files, you can skip this step without cloning the repository. Open Git Shell and enter the command line. First, we need to clone our new repository on GitHub. Before initializing the repository, make sure that the certified public key is correct
$ ssh -T [email protected]
If you receive a successful confirmation message, you can start cloning the remote repository (take one of my projects as an example)
$ git clone https://github.com/jerryhanjj/baike_spider.git
The address of the remote warehouse can be found on your own
Github
project (take mine as an example)
After cloning the warehouse, the project folder and files appear in the folder, enter the project folder, and initialize it
$ git init
- Upload README file
If
Github
you do not check the Create file when creating the repositoryREADME.md
, you must create theREADME.md
file first, otherwise an error will be reported when uploading the file. If it is already checked, you can skip this step.
$ git init
$ touch README.md
$ git add README.md
$ git commit -m 'first_commit'
$ git remote add origin https://github.com/jerryhanjj/baike_spider.git
$ git push origin master
- upload project
Track all files and folders in the project folder
$ git add .
Enter the submission description for this time, and prepare to submit the tracked file of the changes in the staging area. The description content is in single quotation marks.
$ git commit -m 'first_commit'
Associated with the remote repository, after adding, the name of the remote repository is
origin
, this is theGit
default name, and it can be changed to something else, butorigin
this name can be seen as a remote repository at a glance.
$ git remote add origin https://github.com/jerryhanjj/baike_spider.git
If there is an error
fatal: remote origin already exists
in the association, execute the following statement and then perform the association
git remote rm origin
Push all the contents of the local library to the remote library
$ git push -u origin master
If there is an error while pushing
error:failed to push som refs to.......
, execute the following statement
git pull origin master
Pull and merge the files on the remote warehouse
Github
and push them up again