This article is transferred from: http://blog.sina.com.cn/s/blog_4a0824490102wf5y.html Author: ccpacer
fork: On the github page, click the fork button. Copy someone else's repository to your own repository.
clone: clone the repository in github to your local computer
Question: The role of pull request
For example, on the premise that the owner of the warehouse (A) did not add us as a project collaborator, we clone a warehouse named "a" in A's warehouse to our own computer, and modify it on our own computer, but we You will find that we can't contribute code to B through push.
So to contribute your code to B, we should:
- Fork project a in A's warehouse (at this time, our own github has an identical warehouse a, but the URL is different)
- Push our modified code to warehouse B in our github
- pull request , the master will receive the request and decide whether to accept your code or not
- You can also apply as a contributor to project a, so you can push directly
1. git fetch: It is equivalent to getting the latest version from the remote to the local, it will not automatically merge
git fetch origin master
git log -p master..origin/master
git merge origin/master
The meaning of the above command:
first download the latest version from the master branch of the remote origin to the origin/master branch,
then compare the difference between the local master branch and the origin/master branch, and
finally merge
The above process can actually be carried out in the following clearer ways:
git fetch origin master:tmp
git diff tmp
git merge tmp
Get the latest version from the remote to the local test branch and
then compare and merge
2. git pull: equivalent to getting the latest version from the remote and merge to the local
git pull origin master
The above commands are actually equivalent to git fetch and git merge
. In actual use, git fetch is safer
because we can check the update before merging, and then decide whether to merge or not.