Git obtains the latest version from a remote Branch to a local machine with the following two commands:
1. Git fetch: equivalent to obtaining the latest version from a remote device to the local device, without automatic merge
Git fetch origin master git log-P master .. origin/mastergit merge origin master:
First, download the latest version from the master branch of the remote origin to the origin/Master branch.
Then compare the differences between the local master Branch and the origin/Master Branch
Merge at last
The above process can be implemented in the following clearer ways:
Git fetch origin master: tmpgit diff tmpgit merge TMP gets the latest version remotely to the local test Branch
And then compare and merge
2. Git pull: equivalent to obtaining the latest version from a remote device and merge to the local device.
Git pull origin master the above commands are actually equivalent to git fetch and git merge
In practice, git fetch is safer
Because before merge, we can check the Update Status and then decide whether to end the merge.
Difference between git fetch and git pull