CDM Version Control & Collaboration 2 — Questions and Answers
Question 1: In a Git workflow, what is the role of a 'code owner' file (e.g., CODEOWNERS)?
- It lists developers with admin privileges to the repository
- It automatically assigns reviewers based on file paths when a pull request is opened (Correct answer)
- It defines which files are excluded from version control
- It specifies the license owner for the codebase
Correct answer: It automatically assigns reviewers based on file paths when a pull request is opened
A CODEOWNERS file maps file patterns to responsible team members, causing the platform to auto-request reviews from those owners when the relevant files change in a PR.
Question 2: What is semantic versioning (SemVer) and which format does it follow?
- A tagging system using dates; format YYYY-MM-DD
- A three-part versioning scheme; format MAJOR.MINOR.PATCH (Correct answer)
- A two-part versioning scheme; format MAJOR.MINOR
- A hash-based versioning system; format SHA-HASH
Correct answer: A three-part versioning scheme; format MAJOR.MINOR.PATCH
SemVer uses MAJOR.MINOR.PATCH where MAJOR increments on breaking changes, MINOR on backwards-compatible features, and PATCH on backwards-compatible bug fixes.
Question 3: Which Git feature allows developers to save uncommitted changes temporarily without creating a commit?
- git archive
- git stash (Correct answer)
- git tag
- git bisect
Correct answer: git stash
git stash temporarily shelves uncommitted changes in a stack, allowing the developer to switch context and later restore those changes with git stash pop.
Question 4: What is a 'fork' in the context of Git collaboration platforms like GitHub?
- A copy of a repository in your own account, used to propose changes via pull requests (Correct answer)
- A branch created from a tag
- A rollback of the repository to a previous state
- A mirror of the repository on a different hosting platform
Correct answer: A copy of a repository in your own account, used to propose changes via pull requests
Forking creates a personal copy of another user's repository, enabling you to freely experiment and submit contributions back via pull requests without write access to the original.
Question 5: What does 'git bisect' help a developer accomplish?
- Split a branch into two parallel branches
- Identify the specific commit that introduced a bug using binary search (Correct answer)
- Merge two branches into a common ancestor
- Compare two different repository remotes
Correct answer: Identify the specific commit that introduced a bug using binary search
git bisect performs a binary search through commit history, marking commits as good or bad until it pinpoints the exact commit that introduced a regression.
Question 6: In DevOps, what is the key advantage of using short-lived feature branches over long-lived feature branches?
- Short-lived branches require more documentation
- Short-lived branches reduce merge conflicts and integrate feedback more frequently (Correct answer)
- Short-lived branches enforce stricter code review policies
- Short-lived branches eliminate the need for CI pipelines
Correct answer: Short-lived branches reduce merge conflicts and integrate feedback more frequently
Short-lived branches diverge from the main branch for a brief period, minimizing merge conflicts and enabling continuous integration of small, reviewable increments.
Question 7: What is the purpose of a Git tag, and how does it differ from a branch?
- A tag marks a specific point in history as immutable; a branch is a movable pointer to commits (Correct answer)
- A tag is a temporary reference; a branch is permanent
- A tag creates a new line of development; a branch does not
- Tags and branches are functionally identical in Git
Correct answer: A tag marks a specific point in history as immutable; a branch is a movable pointer to commits
Tags create a fixed, named reference to a specific commit (typically a release), while branches are mutable pointers that advance with each new commit.
In a Git workflow, what is the role of a 'code owner' file (e.g., CODEOWNERS)?