CDM Version Control & Collaboration 1 — Questions and Answers
Question 1: Which Git branching strategy uses two long-lived branches — 'main' and 'develop' — along with supporting feature, release, and hotfix branches?
- GitHub Flow
- Trunk-Based Development
- Gitflow (Correct answer)
- Feature Flag Branching
Correct answer: Gitflow
Gitflow, introduced by Vincent Driessen, defines two permanent branches (main and develop) plus temporary supporting branches for features, releases, and hotfixes.
Question 2: In Trunk-Based Development, how frequently should developers integrate their changes into the main branch?
- Once per sprint
- At least once per day (Correct answer)
- Once per week
- Only after full feature completion
Correct answer: At least once per day
Trunk-Based Development requires developers to commit small, incremental changes to the trunk (main branch) at least once per day to minimize integration pain.
Question 3: What is the primary purpose of a pull request (PR) in a collaborative Git workflow?
- To automatically merge code into production
- To notify the team of a new repository
- To propose and review changes before merging into a target branch (Correct answer)
- To create a backup of a branch
Correct answer: To propose and review changes before merging into a target branch
A pull request is a collaboration mechanism that allows developers to propose changes, discuss them, request reviews, and merge code only after approval.
Question 4: Which Git command is used to apply a specific commit from one branch onto another branch without merging the entire branch history?
- git merge
- git rebase
- git cherry-pick (Correct answer)
- git stash
Correct answer: git cherry-pick
git cherry-pick applies the changes introduced by an existing commit onto the current branch, allowing selective porting of individual commits.
Question 5: What does 'git rebase' do compared to 'git merge' when integrating changes from a feature branch?
- Rebase creates a merge commit; merge does not
- Rebase rewrites commit history to produce a linear history; merge preserves divergent history with a merge commit (Correct answer)
- Rebase deletes the source branch after integration
- Rebase and merge produce identical outcomes in all cases
Correct answer: Rebase rewrites commit history to produce a linear history; merge preserves divergent history with a merge commit
git rebase replays commits on top of a new base, producing a linear history, whereas git merge creates an explicit merge commit that shows where branches joined.
Question 6: Which practice ensures that secrets and credentials are never committed to a Git repository?
- Using only private repositories
- Storing secrets in environment variables and using .gitignore for secret files (Correct answer)
- Encrypting the entire repository
- Committing secrets in a separate 'secrets' branch
Correct answer: Storing secrets in environment variables and using .gitignore for secret files
Environment variables and .gitignore rules prevent sensitive files from being tracked, while tools like git-secrets or pre-commit hooks enforce this policy automatically.
Question 7: What is a 'protected branch' in platforms like GitHub or GitLab?
- A branch that is encrypted at rest
- A branch with restrictions preventing direct pushes or requiring status checks and reviews before merging (Correct answer)
- A branch only accessible to repository administrators
- A branch that automatically deploys to production
Correct answer: A branch with restrictions preventing direct pushes or requiring status checks and reviews before merging
Protected branches enforce policies such as requiring pull request reviews, passing CI checks, and disallowing force pushes, safeguarding critical branches like main.
Which Git branching strategy uses two long-lived branches — 'main' and 'develop' — along with supporting feature, release, and hotfix branches?