Home >Development Tools >git >What is the difference between pull and fetch in git

What is the difference between pull and fetch in git

WBOY
WBOYOriginal
2022-01-07 15:01:5440906browse

Difference: 1. fetch can directly change the remote tracking branch, while pull cannot directly operate on the remote tracking branch; 2. fetch will not automatically merge or modify the current work when pulling data to the local warehouse, and pull will not automatically merge or modify the current work. Get the latest version from the remote and merge it locally, automatically merging or modifying the current work.

What is the difference between pull and fetch in git

The operating environment of this article: Windows 10 system, Git version 2.30.0, Dell G3 computer.

What is the difference between pull and fetch in git

The difference between Git fetch and git pull is: different remote tracking branches and different pulls , commitID is different.

1. Different remote tracking branches

1. Git fetch: Git fetch can directly change the remote tracking branch.

2. git pull: git pull cannot directly operate on the remote tracking branch. We must first switch back to the local branch and then create a new commit.

2. Different pulls

1. Git fetch: Git fetch will pull data to the local warehouse - it will not automatically merge or modify the current work .

2. git pull: git pull obtains the latest version from the remote and merges it locally. It will automatically merge or modify the current work.

3. Different commitIDs

1. Git fetch: Use Git fetch to update the code. The commitID of the master in the local library remains unchanged and is still equal to 1.

2. git pull: Use git pull to update the code. The commitID of the master in the local library changes to 2.

Recommended study: "Git Tutorial"

The above is the detailed content of What is the difference between pull and fetch in git. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn