Automation, Orchestration, and Scripting
A developer wants to see the commits teammates pushed to the remote's main branch without changing the files in the current branch. Which command should the developer run first?
Show the answer
Correct answerC. git fetch origin
AWhy not this: git pull fetches and then merges or rebases into the current branch, which changes its files.
BWhy not this: git merge changes the current branch, and without a fetch first origin/main is not up to date.
CWhy this is right: Git fetch updates remote-tracking branches such as origin/main and leaves the working tree untouched.
DWhy not this: git rebase rewrites the current branch onto origin/main, which changes its files.
git fetch updates remote-tracking refs such as origin/main and leaves the local branch and working tree untouched. git pull differs because it runs a fetch followed by a merge or rebase into the current branch.