GitHub usage: how to use github

Source: Internet
Author: User

For more information about how to use GitHub, see the instructions on the official website. This document is intended only for common and error-prone usage instructions. Only personal opinions.
 
 
How to use GitHub?
 
 
(1) It is often used to create a version library on GitHub first, and then create a version library on the local machine. Note that it is not necessarily the same as the file name of the original version. For example, if the original version is HelloWorld, the local machine can use a folder named HelloRyan. You only need to configure the relevant information in subsequent operations.
 
 
(2) Configure Git after creating a folder on the local machine. First, git init is used to initialize a version library, and then you need to establish a connection with the remote version library. Use the git remote add command to add a remote connection.
Git remote add origin url
The origin is the alias of the url you specified. You can use other names. The url is the path corresponding to the version library information. Here, there is an SSH/HTTP/Git Read-Only option on the version library you created on GitHub, all you need to do is select a url and enter it. For example
Git remote add helloworld git@github.com: username/repname. git
 
 
(3) After establishing the connection between the local machine and the remote machine, you can also perform simple configuration on Git, such as mailbox, user name, and comparison tool. This article is not a preliminary tutorial, therefore, this part is omitted. For more information, see the official documentation.
 
 
(4) local project development, such as creating a file and then submitting it. And so on.
 
 
(5) To ensure remote synchronization, you need to push the local version Library to the remote. Therefore, use:
Git push origin branch
Where, origin is the alias just obtained, such as helloworld, and the branch name to be pushed, such as master. It depends on the alias of your local and remote branches.
 
 
(6) After the above changes are completed, the Code may be pulled in another scenario. At this time, the same steps are taken to create a folder and git init is used to initialize the version library, then, git remote add xxx.
The next task is to execute the pull command: git pull xxx branch (where xxx is the previous origin and helloworld aliases ).
 
 
The simple usage is described here.
 
 
The following describes some of the experiences and conclusions used.
 
 
(1) The first is about git remote add xxx usage. This method is to take the alias, avoiding entering the complete path name every time. Of course, you can also do this, of course, no problem.
For example, git pull url master pulls the remote url to the master branch of the local machine.
However, every time this is a lot of trouble, the alias will be used to push and pull directly.
In fact, after this operation last night, an item will be written to the config file under the. git directory to indicate the information of this alias, as shown below:
[Remote "origin"]
Url = git@github.com: xxx/rep. git
Fetch = + refs/heads/*: refs/remotes/origin /*
The above is the information of the alias origin. The address of the target remote version library is recorded.
 
 
(2) SSH or HTTPS.
The SSH mode and HTTPS mode in the version library are different, specifically, the url Information is different, but the actual authentication mechanism is also different. After a local key is created, you do not need to authenticate the key again in ssh mode, but you need to enter the password for https each time.
For example, the above url = git@github.com: xxx/rep. git uses ssh, so when I enter a version library and push it to a remote location, I do not need to enter the user name and password. This is only used in your initial use. If my url is used in https mode, such as url = https: // xxxx, it is convenient for me to update, push, or pull.
 
 
(3) Common commands and Git usage do not seem to require much explanation, but it still requires a lot of effort to master this tool. Here, we recommend you use the tool TGit (Windows) and gitg (Linux. Graphical tools can help us get familiar with submitting graphs and master basic operations. Sometimes, the graphical interface can greatly facilitate our operations, such as right-clicking a Tag, viewing branches, all branches, and Diff.
In Windows, install the Git program, install TGit, and specify the Git path. You can use the command line interface of Cygwin to operate Git, you can also right-click the menu and use TGit to view the submission diagram.
In Linux, you can directly use the command line to work, and use graphical tools such as gitg to observe the submission diagram.
 
 
(4) collaborative work. There are many open-source projects on GitHub that can be involved in development and learning. You can search for related projects, fork the project, and then it will appear in your own version library. At this time, you can update it to your local machine through pull, then proceed with the development. After the development, push it up and send a request to the developer to let the developer know about your repair. Then, the developer determines whether to adopt it based on his own judgment, update the version library to determine whether to merge your submission into the version library.
 
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.