[Git] The difference between git pull and git fetch

fetch

  • Principle: Git fetch pulls the latest content of the remote host to the local, and pulls all the data you don't have yet. After the execution is complete, you will have references to all branches in that remote warehouse, which can be merged or viewed at any time.

  • All updates of a remote host are retrieved from the local
    git fetch <remote host name>

  • Retrieve the master branch of the origin host:
    git fetch origin master

pull

  • Explanation: It is to pull down the latest content of the remote host and merge it directly, namely: git pull = git fetch + git merge, this may cause conflicts and need to be resolved manually.

Application scenarios

The git fetch command will pull the data to your local warehouse-it will not automatically merge or modify your current work. You must manually incorporate it into your work when it is ready. git pull usually grabs data from the server where it was originally cloned and automatically tries to merge into the current branch. Relatively speaking, the operation of git fetch + git merge is root safe.

Guess you like

Origin blog.csdn.net/m0_46537958/article/details/108326514
Recommended