DevOps Version Control & Git Workflows 2 — Questions and Answers
Question 1: What is the difference between 'git fetch' and 'git pull'?
- git fetch downloads and merges changes; git pull only downloads
- git fetch only downloads remote changes; git pull downloads and merges them (Correct answer)
- git fetch works on branches; git pull works on tags
- git fetch requires authentication; git pull does not
Correct answer: git fetch only downloads remote changes; git pull downloads and merges them
'git fetch' retrieves remote changes into your local repo without modifying your working branch, while 'git pull' fetches and automatically merges.
Question 2: Which strategy minimizes merge conflicts by keeping feature branches short-lived and merging frequently?
- Gitflow
- Release branching
- Trunk-Based Development (Correct answer)
- Environment branching
Correct answer: Trunk-Based Development
Trunk-Based Development keeps branches short-lived (hours to a day) and promotes frequent integration, dramatically reducing merge conflict risk.
Question 3: What is a 'pull request' (or 'merge request') primarily used for in a team DevOps workflow?
- Requesting access to a protected repository
- Pulling configuration from a remote server
- Proposing code changes and triggering peer review before merging (Correct answer)
- Downloading the latest build artifacts from CI
Correct answer: Proposing code changes and triggering peer review before merging
Pull requests provide a structured way for developers to propose changes, discuss them, run automated checks, and get peer approval before merging.
Question 4: What does 'git cherry-pick' do?
- Selects the best version of a file during conflict resolution
- Applies a specific commit from one branch onto another (Correct answer)
- Removes unwanted commits from the repository history
- Compares two branches and picks the newer changes
Correct answer: Applies a specific commit from one branch onto another
'git cherry-pick' copies a specific commit by its hash and applies it to the current branch, useful for backporting fixes.
Question 5: In Git, what is 'origin' by default?
- The first commit ever made in the repository
- The default name for the remote repository a project was cloned from (Correct answer)
- The main branch of a repository
- A Git alias for the local working directory
Correct answer: The default name for the remote repository a project was cloned from
When you clone a repository, Git automatically names the source remote 'origin', which serves as the default push/pull target.
Question 6: What Git workflow practice does DORA research identify as a key predictor of high software delivery performance?
- Using only release branches for all changes
- Working in small batches with trunk-based development (Correct answer)
- Requiring multi-day code reviews before any merge
- Tagging every commit with a version number
Correct answer: Working in small batches with trunk-based development
DORA research consistently finds that working in small batches with trunk-based development correlates strongly with elite software delivery performance.
Question 7: Which Git command shows the commit history including all branches in a visual graph format?
- git log --all --graph --oneline (Correct answer)
- git history --visual --branches
- git show --tree --all
- git branch --graph --verbose
Correct answer: git log --all --graph --oneline
'git log --all --graph --oneline' renders an ASCII graph of all branch histories in a compact single-line format.
What is the difference between 'git fetch' and 'git pull'?