I have been using SourceTree under the guidance of my colleagues since I started working. Today, I finally try to contact GitHub. Actually, it is not difficult or complicated, but I have mystified it under the influence of others long ago. This small course focuses on practical operation and process record, suitable for those who want to contact but have not actually operated.

What is GitHub for? For beginners like me, the first thing I realize is that GitHub is the hosting platform of the project code. How can I host the project code?

It can be roughly divided into three parts:

  • Set up a Github account
  • Generate the SSH key key
  • New warehouse, upload, pull files

I sorted out the general process by myself. A simple imagination is as follows: Our car needs to enter the parking lot through the gate. The simple image drawn is as follows:

After computer1 obtains the key, it does not need to obtain any resources on the device again. However, any access operation needs to record the corresponding name and other information. If we use a new device, Computer2, of course, needs to obtain a new SSH key again and add it.

After installing Git on your PC and registering with your GitHub account, you can start from scratch.

Generate the SSH key key

3. Create a local folder for resources and create or add new files in it, as shown in the figure below:

4. In the resource folder, right click on the blank and click git bash.

5. Configure your own Git information in the command window

git config --global user.name "Zhang San"Git config --global user.email"[email protected]"Ssh-keygen -t rsa-c"[email protected]"// Create an SSH key locally to generate a keyCopy the code

Change the configuration to your own name and email address, because github records this information every commit. Then disk C –> user –> own user name generated under the.ssh folder.

SSH folder — Notepad open –id_rsa.pub, as shown in the figure below:

7. Go back to GitHub, click on your profile picture, select Settings, and create a new SSH key.

8. Fill in the title and key(contents of id_RSA. pub notepad) and click Add, as shown in the picture:

When this step is complete, the computer has the permission to submit or pull to the corresponding Github

Note: as long as the operation on the same computer can not do this step.

New warehouse, upload, pull files

Create a warehouse

1. Open GitHub official website to create a new managed repository, as shown in the picture:

2. Fill in the name and description of the new managed warehouse and click Create, as shown in the picture:

Use the new GitHub repository

  • Initialize the warehouse
  • Establish a connection
  • Commit or pull
 git init
Copy the code

2. Establish a connection and open the repository to copy the SSH address

Re-enter the address link

git remote add origin [email protected]:VivianFive/RecordStep-One.git
Copy the code

If any error occurs, delete it and enter it again

 git remote rm origin 
 git remote add origin [email protected]:VivianFive/RecordStep-One.git
Copy the code

3. Submit or pull

Three steps to submit

git add --all
git commit -m 'Remarks'
git push -u origin master
Copy the code

You can also combine steps

git commit -am "Remarks information"
git push
Copy the code

Pull the code

git pull origin master
Copy the code

If the above can not meet their own use requirements, you can use help to select the appropriate use

git help/ / see the githelp -add 
Copy the code

The above is just my first contact with GitHub operation steps, record it for my convenience, if there is any improper criticism welcome.