Working with Remotes — push, pull, fetch — Concept Check
Questions on Working with Remotes — push, pull, fetch. Remotes are named URLs to other copies of your repository. push sends your commits upstream; fetch downloads remote changes without merging; pull = fetch + merge. Understanding the difference between fetch and pull prevents nasty surprises.
Questions in this quiz
8 questions on Working with Remotes — push, pull, fetch — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.You have cloned a repository and want to see the configured remotes. Which command should you use?
- Agit pull origin main
- Bgit remote -v
- Cgit push -u origin main
- Dgit fetch --all
2.After running 'git fetch origin', what is the status of your local main branch?
- AIt remains unchanged.
- BIt is merged with origin/main.
- CIt is updated with the remote changes.
- DIt is deleted if not in sync.
3.You want to switch your remote URL from HTTPS to SSH. Which command allows you to do this?
- Agit remote remove origin
- Bgit remote set-url origin git@github.com:user/project.git
- Cgit remote add origin git@github.com:user/project.git
- Dgit remote rename origin git@github.com:user/project.git
4.A developer runs 'git pull' and encounters a merge conflict. What caused this?
- AThe pull operation included a merge.
- BThe local branch is ahead of the remote.
- CThe fetch operation failed.
- DThe remote branch was deleted.
5.You want to ensure a cleaner history when pulling changes. What should you do?
- AUse 'git push --force' regularly.
- BUse 'git pull --rebase' instead of 'git pull'.
- CAlways use 'git fetch' followed by 'git merge'.
- DDelete remote branches after merging.
6.A colleague claims 'git fetch' updates your working directory. What is the truth?
- A'git fetch' deletes unsynced local branches.
- B'git fetch' updates both remote-tracking and local branches.
- C'git fetch' automatically merges changes.
- D'git fetch' only updates remote-tracking branches.
7.You want to push a new branch and set it to track the remote branch. Which command achieves this?
- Agit push -u origin new-feature
- Bgit push origin new-feature
- Cgit fetch origin new-feature
- Dgit pull origin new-feature
8.What happens if you use 'git push --force' on a shared branch?
- AIt is the preferred method for updating branches.
- BIt only affects your local repository.
- CIt rewrites history and can lose others' work.
- DIt safely updates the branch without conflicts.