Which statement best describes the difference between git fetch and git pull?
Think about whether the command updates your working files immediately or just updates remote tracking information.
git fetch downloads new data from the remote repository but does not change your working files or current branch. git pull is like running git fetch followed by git merge, so it updates your current branch with remote changes.
You run git fetch origin on your local repository. What is the immediate effect on your local branches?
Consider if your working files or local branches change immediately after fetching.
git fetch updates remote tracking branches like origin/main but does not change your local branches or working files until you merge or rebase.
In a team project, you want to review changes from others before merging them into your branch. Which command should you use and why?
Think about how to avoid automatic merges that might cause conflicts without your knowledge.
git fetch lets you download remote changes without merging. You can inspect changes safely before deciding how to integrate them. git pull merges immediately, which might cause conflicts unexpectedly.
You ran git pull and got merge conflicts you did not expect. What is the most likely cause?
Think about what happens when you merge changes automatically without checking first.
git pull runs git fetch then merges. If local and remote changes overlap, conflicts can occur unexpectedly. Fetching first allows review before merging.
Which practice is best to keep your local branches updated safely without losing work?
Consider how to avoid losing work and how to review changes before merging.
Fetching first and reviewing changes before merging or rebasing helps avoid conflicts and accidental overwrites. Force pushing or deleting branches can cause data loss.