What is the difference between git fetch and git pull?
git pull is git fetch followed by git merge.
| git fetch | git pull |
|---|---|
| Downloads new commits from the remote | Downloads and merges them into your current branch |
| Your files and branch do not change | Your files and branch change |
Safe, you can review first with git log HEAD..origin/main | Can create a merge commit or a conflict |
Works for all branches (--all) | Works for the current branch |
Use fetch when you want to see what changed before merging, and pull when you just want to update your branch. See Git Fetch and Pull.
Learn more about the similar topics:
| Tutorials |
|---|
| Git Clone |
| Git Remote |
| Git Push |
| Git Fetch and Pull |
| Exercises & Assignments |
|---|
| Clone a repository, make a change and push it |
| Get new changes from the remote with fetch and pull |