See a lot of different things about git fetch and git pull from Baidu
Practice:
Create a new project from GitHub try,copy to Local.
Modify the Readme.txt file on the GitHub website and add a new "alter README"
In the local warehouse Readme.txt also added a new sentence, "Add some thing"
It is not possible to commit the local code to GitHub now. An error message will appear!!!
You should download the code from the remote repository first
(1) What happens with git pull?
Git pull Origin Master
Open the Readme.txt file for the local warehouse
gitPull: the equivalent of getting the latest version from remote and merge to local
(2) using the git fetch command
Next up, we've changed the code of the conflict and submitted it.
Add use fetch on the Readme.txt file
Readme.txt file modification in the local repository, add use Fetch Loca
L
Submit the code locally and submit the code, as shown above, cannot be submitted up
Input
Git fetch Origin Master
Open a Readme.txt file without any changes
We re-enter
Git log-p master: Origin/master
You can see who has changed the code in the remote repository, and how to modify it
And then enter
git merge Origin/master
Manual Merge Warehouse
Then let's take a look at the Readme.txt file
Fetch is equivalent to getting the code modified on the GitHub remote repository,
You can log-p master via git. Origin/master to see the different
Finally, merge the code according to your needs
Conclusion: Pull is equivalent to a fetch operation plus a merge operation.
But fetch better, you can check the update before merging.
The difference between git pull and git fetch