GitHub as a programmer's back garden, do you really have fun? Super, super detailed GitHub tutorial!

Commonly used commands:

git init creates an empty warehouse

git status View status git add. Add files

git commit -m'comment' Submit the added file and note the description

git remote add origin xxx connect to remote warehouse

git push -u origin master pushes local warehouse files to remote warehouse

git log View the change log

git reset --hard The first six digits of the version number return to the specified version

git branch view branch

git branch newname creates a branch called newname

git checkout newname switches to the branch called newname

git merge newname merge the newname branch to the current branch

git pull origin master pulls the content on the master branch to the local

Submit an overall demonstration legend, please continue to read the latter part for details:

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

One: Introduction

First of all, let me give a brief introduction to GitHub. GitHub has a very powerful function. You can create a library on the server (how to create it later). Writing code is a very heavy task, especially When many people complete a large project, it is very complicated. When a group of people work together on a certain project, the time to complete and the progress of the completion are different. If you write something, I will write a little, maybe even today. There was an error in the writing, which affected the code I wrote yesterday. In the end, how can we easily summarize everyone's code, and how can we find a series of problems after summarizing everyone's code? So we use the GitHub software. We have a main repository on the GitHub server, which is used to store all your code. If you don’t pay, everyone can see it. If you don’t want others to see your code, you can choose a paid repository. After we have created the main warehouse, we can create branches on the computer, and then you can complete your own code on the computer, and directly synchronize the branches on the computer after writing. When you think you can upload your own main warehouse, just You can apply for an update. When you pass the review, your code appears in your main repository, so that programmers all over the world can view your code. There are now 3 million registered users all over the world, and even some fairly well-known open source projects have released their code among them. On GitHub you can see many of their own codes shared by elites in the computer field. These are the two main advantages of GitHub, which is suitable for teamwork and downloading the code of other excellent people.

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

https://github.com/  This is the official website of GitHub. You can register your own GitHub account on the official website. The website is all in English. For students who are not good at English, it is recommended to use Google Chrome, which can translate web pages. It is very convenient to use in Chinese.

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

After going through the simple steps, you will have your own GitHub account. After the simple registration is completed, you will need to verify the email address you entered to use your GitHub normally.

After the registration is complete, after completing some simple settings, you need to create your own library

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

After logging in to your GitHub account, the small plus sign in the upper right corner of the web page is a button to create your own library. After the web page is translated into Chinese in the subsequent steps, follow the prompts to create your own library.

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

The first box is a name for your library, and the second box is a brief introduction to the library.

After creating your own library, let your computer clone a library created by yourself, and synchronize the code on your computer to the library you created on GitHub.

In order to achieve this, you need to install a software, Git Bash.

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

Now I will introduce the installation and simple configuration of this software.

git-scm.com First enter the GitHub official website, download the version suitable for your computer

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

Run after downloading the installation package

In the installation process, you can directly default the options.

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

First, create an ssh key locally. The purpose of this is that you now need to obtain a key on your computer, which is the same thing as our usual verification code. After obtaining it, enter it in your GitHub account, and your computer will be Linked with your GitHub account, so that you can easily upload your code at any time through Git bash in the future. Here's how to enter this key into your GitHub if you get it.

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

This column starts with the name of your computer, here it is Hanani @The content behind is your computer model, many times when someone opens @后边, it is garbled, don’t care at this time, because some computer models are in Chinese , There may be a problem in the display, which will not affect your later operation.

Next, we must start to obtain your own key. All functions in git bash are implemented through some simple codes. Need to enter when getting the key

$ ssh-keygen-t rsa-C "[email protected]"

You need to enter this code, and the quotation marks need to be changed to the email account you bound when you registered for GitHub. After that, there will be some simple operations for you to confirm, and then you will be prompted for the operation path, password, etc. Under normal circumstances, just press Enter and go all the way.

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

If this interface appears later, it means that your key has been successfully created. Now you need to go to the storage location he just displayed to open it, and copy the contents.

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

In the .ssh folder

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

You will see these later. Some people will have a pub behind id_rsa. Before reading the online tutorial, you need to find the file with pub, because I didn’t have a .pub file after it was generated, so I opened id_rsa with anxiety Later I found that the key here is also usable. When opening id_rsa, you need to open it in notepad.

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDIskXqZF3SSFtACK6zoNGJabikTBC3kig6+4j4dCq1tswhA9YkuJCi0WpRmGYWBQ67dyT2or7RedFZlULLZN3nL6AWlo5V2jRXw4WQxCon2rU1p122wmiTzqYOfsykjwullWV4bYcZU4n77A4/9WwlSqZCpEbcdwV8IMkvwfJUInSWqTvmYMcKTWu8yad5DZ2v7LBWfgsL/Tfx7aEB8UjDNJ6SPw30Yijy+62YrftYGgbuwoiL9hDNGO2LfjgOkglHTBJaZe31uQLLWc5uCzd+7Dgh7RaKMmeuz2Uv7yqm/IEU9jH8cPMR9YRPIhmzg38G2s9ILn27QqW9j1hrFY1V [email protected]

This is the key that I got. After opening it, there is a long period of time. Don't be surprised, there is no problem. This is the key you need.

Now you need to log in to your GitHub and add this key,

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

Open your GitHub settings interface and find the SSH and GPG keys option, there is an add new SSH keys in the upper right corner of the webpage, click

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

The title here is for you to give your key a name, whatever name you like according to your personal preference, and then fill in the key you copied in the file just now in the big box below. Save it.

Then you can go back to your Git bash

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

Then enter the code above to check whether the binding is successful. When you bind for the first time, you will be prompted whether to continue after entering the above code. After entering yes, if it appears: You've successfully authenticated, but GitHub does not provide shell access. That means that you have successfully connected to GitHub. Next, you need to simply set up some things.

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

Enter the code above, the name should be the same as the one on GitHub, and the email must be the email address registered with GitHub

The order of the two can be reversed, and there is no fixed order.

Next, clone your library to your local computer, so that you can upload the code later.

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

After the library is created, a URL will appear on the web page.

Personally, I’m used to storing my files in drive d, so you first need to locate git bash in drive d

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

Enter cd /D in git bash. Note that the name of the disk must be capitalized. If you do not enter this statement and do not locate git bash, the default local file location is in the c drive.

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

After inputting, /D will appear, indicating that the positioning is successful.

After entering

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

The URL behind git clone is the URL after you successfully created the library

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

Then open the D drive I located

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

As you can see, there is already a folder created with my library name in Disk D.

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

Open this folder and create a file with any format and any name in it.

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

Then relocate git to place the book in the folder of your library.

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

Then enter the ls statement. The function of ls is to view the files in the folder you are currently located. Now you can see that the test file I just created has appeared.

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

Then enter git add test.txt

After that, enter and then git commit -m "cc" The content in the quotation marks can be changed at will. This statement means to give you a note on the file you just uploaded, which is convenient for searching and remembering.

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

The above situation occurs after input, and then after input git push origin master, a

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

Interface, log in to your previously registered GitHub account and click login here.

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

If this happens later, it means that the login failed. At this time, you need to enter your GitHub account name

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

This interface will appear after entering, and then enter your GitHub password again.

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

When a similar interface appears, you can cheer, which means you are successful.

Now open your GitHub website and find the library you created

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

Found that today's grid is already green, indicating that you have uploaded the file you just created.

After that, you only need to put your code in the corresponding folder of the library, and then use git add, git commit -m "", and finally git push origin master to submit your code.

Reference to understand

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

GitHub man’s paradise, do you really have fun?  Super super detailed GitHub tutorial

 

Guess you like

Origin blog.csdn.net/weixin_48612224/article/details/109232190