Current location - Health Preservation Learning Network - Slimming men and women - GitHub, a paradise for men, do you really play? Super detailed GitHub tutorial
GitHub, a paradise for men, do you really play? Super detailed GitHub tutorial
abstract:

Git init creates an empty warehouse.

Git state view state git add. Add files.

Git commit -m' comments' submits the added file and adds comments.

Git remote add origin xxx connects to the remote warehouse.

Git push -u origin master pushes local warehouse files to remote warehouses.

Git log view change log

Git reset-The first six digits of the hard version number are returned to the specified version.

Git branch view branch

Git branch newname creates a branch named newname.

Git checkout newname switches to a branch named newname.

Git merge newname merges the newname branch into the current branch.

Git pull origin master locally extracts the content on the master branch.

One: Introduction

First of all, let me briefly introduce GitHub. GitHub has a very powerful function, that is, you can create a library on the server (how to create it will be introduced later). Writing code is a very heavy job, especially when many people finish a very large project, which is very complicated. A group of people write a project together, and the completion time and progress are different. You write a little, I write a little. What you wrote today may even be wrong, affecting the code I wrote yesterday. Finally, how to summarize your code conveniently, how to find errors after summarizing your code, and so on. In this way, we use GitHub software. We have a main warehouse on the GitHub server 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 warehouse. After we create the main warehouse, we can create branches on the computer, and then you can complete your own code on the computer. After writing, you can directly synchronize with the branches on the computer. When you think you can upload your main warehouse, you can apply for an update. After approval, your code will appear in your own main warehouse, so that programmers all over the world can view your code. Now there are 3 million registered users all over the world, and even some well-known open source projects publish code in it. On GitHub, you can see your own code shared by many elites in the computer field. These are the two main advantages of GitHub, which are suitable for teamwork and downloading other excellent codes.

/This is the official website of GitHub. You can register your GitHub account in official website. The online service is in English. For students with poor English, it is recommended to use Google browser, which can translate web pages into Chinese and is very convenient to use.

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

After registering and completing some simple settings, you need to create your own library.

After logging into your GitHub account, the small plus sign in the upper right corner of the webpage is a button to create your own library. After translating the webpage into Chinese, follow the prompts to create your own library.

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

After creating your own library, let your computer clone the library you created and synchronize the code on your computer with the library you created in GitHub.

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

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

Git-scm.com first entered GitHub official website and downloaded a version suitable for his computer.

Run after downloading the installation package.

Simply default the options directly during installation.

First, create an SSHHKEY locally. The purpose of this is that you need to get a key on your computer now, which is the same as our usual verification code. After you get it, enter it in your GitHub account, and your computer will be linked with your GitHub account, so that you can upload your code at any time through Git bash very conveniently. If you get this key, here's how to enter it into your GitHub.

The beginning of this column is the name of your computer. As far as I'm concerned, the content behind Hanani @ is your computer model. Many times, when someone opens it, @ is garbled. Don't worry about it at this time, because some computer models are in Chinese, and there may be problems when they are displayed, which will not affect your later operation.

Next, start taking your own keys. All the functions in git bash are implemented with simple code. You need to input to get the key.

$ ssh-keygen-t RSA-C " your _ email @ your email . com "

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

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

Yes. Ssh folder.

After that, you will see these contents. Some people will open a pub after id_rsa. Before watching the online tutorial, I need to use pub to find the file, because I didn't bring the file. Generation after generation of pubs. After opening id_rsa with trepidation, I found that the key inside can also be used. When opening id_rsa, you need to open it in Notepad.

ssh-RSA aaaaab 3n Zac 1 YC 2 eaaaaadaqabaaaaqdiskxqzf 3 SSF tack 6 zongjabiktbc 3 kig 6+4j 4 dcq 1 tswha 9 ykujci 0 wprmgywbq 67 dyt 2 or 7 redfzlullzn 3n l6 awlo 5 v2 jrxw 4 w qxcon 2 ru 1p 122 mitzqyofsykjwulwulv4 byczu 4n 7

This is the key I got. I haven't opened it for a long time. Don't be surprised, there is no problem. Here is the key you need.

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

Open your GitHub settings interface and find the options of SSH and GPG keys. There is a click to add a new SSH key in the upper right corner of the webpage.

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

Then you can go on with your carnival for nothing.

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

Enter the above code, the name should be the same as GitHub above, and the email address must be the email address where GitHub is registered.

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

Next, you should upload your cook to your local computer so that you can upload the code later.

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

Personally, I am used to storing my own files on disk D, so you need to locate git bash on disk D first.

Enter cd /D in git bash. Please note that the CD name must be capitalized. If this statement is not entered and git bash is not found, then the default local file location is in drive C.

/D will appear after input, indicating successful positioning.

Then enter.

The URL behind git clone is the URL after you successfully create the library.

Then open the D disk I found.

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

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

Then reposition git and find the book in the library folder.

After entering the ls statement, the function of ls is to view the files in the folder where you are currently located. Now you can see that the test file I just created has appeared.

Then type gitaddtest.txt

After input, the contents in gitcommit-m "cc" quotation marks can be changed at will. This sentence means to add a note to the file you just uploaded, which is convenient for finding memories.

The above situation appears after input, and then a will appear after input git to push origin master.

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

If this happens in the future, the login failed, and then you need to enter your GitHub account name.

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

When a similar interface appears, you can cheer, which means you have succeeded.

Now open your GitHub website and find the library you created.

Today's grid is green, which means that you have uploaded the file you just created.

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