The current GitHub is very fire, both domestic and foreign now in use. Take the time to study the use of this thing, and summed up, although a little late, but I think there is a need to understand and learn the place. All right, go to the topic, step-by-step to introduce, of course, the easiest way to learn, of course, follow the steps provided by the GitHub website to learn. I am also here to summarize this content.
1. GitHub website: https://github.com
2, choose Login, enter the user name, password, login. After landing, you will be introduced to the homepage, which contains four basic applications:
Set up Git Create a repositoryfork a repositorybe Social3 and set up a git (the main purpose is to install the Git tool on the local system, because GitHub is actually a Web site that serves git)
1, configure the user name and mailbox. git config--global user.name "Your name Here" # sets the default name for git to use when you commitgit config--global us Er.email "[Email protected]" # Sets the default e-mail for git and use when you commit2, supplemental instructions git version query git--versio n git path query which git4, Create a Repository
After you receive the create repository Web page green button in the webpage, enter the necessary project name and click to complete the process of creating the repository. It is necessary to remember that the project name is hello.git created successfully, it involves how to create a local client's library, in order to ensure the synchronization with the service. The client's library is created as follows: Mkdir ~/hello-world# creates a directory for your project called "Hello-world" in your user directorycd ~/hello-world# changes the current working directory to your newly created directorygit init# Sets up the necessary Git files# Initialized empty Git repository in /users/you/hello-world/.git/touch readme# creates a file called "README" in your Hello-World directorygit add README# Stages your readme file, adding it to the list of files to be committedgit commit -m ' First commit ' # commits your files, adding the message "first Commit "git remote add origin https://github.com/username/hello-world.git# creates a remote named "origin" pointing at your GitHub repogit push origin master# sends your commits in the "Master" branch to github
The above process involves several key points, which I spent some time to figure out in the course of the study. The following one by one explains Git Init is actually creating an initial git extension in an empty directory, or an empty project. Git add Readme is the meaning of uploading a readme file, when the file is more than the case, you need to upload all the files in the directory, this should be written as git ad. Remember to have a point. git commit-m ' comment description ' is actually submitted to the local repository. Git remote add Origin https://github.com/username/Hello-world.git the implication is that the local repository origin is uploaded to the hello-world.git of the server. Git push-u origin master means upload, this place is the real upload.
5. Fork a Repo
Fork understanding, in fact, the meaning of fork is to inform the owner of a git project, I would like to fork your code into my space, and then I can be modified, so that other unauthorized people to contribute to the code. Also, after fork, use git clone https://github.com/username/Hello-world.git after modification, the method bit to be submitted to GitHub, at this time: git remote add upstream https:// github.com/octocat/hello-world.git git fetch ustream to get unchanged content. Here is a concept that is git fetch, and Git pull, In fact, the code is obtained from the server, equivalent to update, but fetch is not automatically overwritten, and pull will be automatically overwritten. In addition, there is a concept, that is, after the clone, Origin point is actually your own repo, and the master change is required by the following, to obtain a specific configuration tracking. Cd spoon-knife# changes the active directory in the prompt to the newly cloned "Spoon-knife" directorygit remote add upstream https://github.com/octocat/spoon-knife.git# assigns the original repo to a Remote called&nBSP; " Upstream "Git fetch upstream# pulls in changes not present in your local repository, without modifying your files My understanding, in fact, is the branch of the problem. The so-called branch, in fact, is the goal when you need to solve two problems at the same time, and these two problems in order to facilitate the subsequent merging, so will create a branch, and then do Meiger, the branch merge, so that the simultaneous problems.
So when you only submit your own changes to yourself, you can do the following: Git push origin master# pushes commits to your remote repo stored on GitHub
And when you need to merge with your host's branch, you need to do the following: Git fetch upstream# fetches any new changes from the original repogit merge upstream/master# Mer Ges any changes fetched into your working files to create a branch method:
Git branch mybranch# creates a new branch called "Mybranch" git checkout mybranch# makes "Mybranch" the active branch is actually to implement a branch, and then the branch as the current branch, to modify. Here's how to change the current branch: git checkout master# makes "master" the active Branchgit checkout mybranch# makes "Mybranch" the active BR Anch Two branch do the final merge git checkout master# makes "master" the active branchgit merge mybranch# Merges the commits from "Mybran Ch "into" master "git branch-d mybranch# deletes the" Mybranch "branch
The basic meaning of pull request is to send a request to the host informing him that I made a change that you can look at.
The basic meaning of unwatch the main repo is that, for many people who are updating the project, I make some choices and discard some updated traces.
Finally, I would like to introduce the method of deleting a project, which is sometimes difficult to find on GitHub, and the method is as follows:
First, select the project--and then choose Setting--Delete this repository
GitHub usage Tips