What is the difference between git fetch and git pull?
Options
- There is no difference, they do the same thing
fetchdownloads only;pullis fetch plus merge (Correct option)pulluploads your changes;fetchdeletes themfetchonly works for tags, not for branches
Answer
fetch downloads remote changes without changing your files; pull = fetch + merge into your current branch
Why
git fetch updates your knowledge of the remote (new commits and branches) but does not touch your working files. It is safe: you can inspect first (git log origin/main).
git pull does fetch and then merges (or rebases, with --rebase) those changes into your current branch immediately. It may cause conflicts you must resolve.
Many people use git pull --rebase to keep a linear history.
Remember
pull = fetch + merge.