DevOps Version Control & Git Workflows 1 — Questions and Answers
Question 1: Which Git branching strategy uses long-lived branches named 'main', 'develop', 'release', and 'hotfix'?
- GitHub Flow
- Gitflow (Correct answer)
- Trunk-Based Development
- GitLab Flow
Correct answer: Gitflow
Gitflow defines a strict branching model with dedicated branches for features, releases, and hotfixes alongside main and develop.
Question 2: What does the command 'git rebase -i HEAD~3' accomplish?
- Merges the last 3 commits into the main branch
- Interactively edits the last 3 commits (Correct answer)
- Resets the repository to 3 commits ago
- Creates a new branch from 3 commits back
Correct answer: Interactively edits the last 3 commits
The '-i' flag enables interactive rebase, letting you squash, reorder, or edit the specified number of recent commits.
Question 3: In Trunk-Based Development, how often should developers integrate their changes into the main branch?
- Once per sprint
- At least once per day (Correct answer)
- After every feature is complete
- Once per release cycle
Correct answer: At least once per day
Trunk-Based Development requires developers to integrate to the main trunk at least daily to minimize merge conflicts and enable continuous integration.
Question 4: What is a 'fast-forward merge' in Git?
- A merge that skips conflict resolution automatically
- A merge where the branch pointer simply moves forward without creating a merge commit (Correct answer)
- A merge that compresses all commits into one
- A merge that only includes changed files
Correct answer: A merge where the branch pointer simply moves forward without creating a merge commit
A fast-forward merge occurs when the target branch has no new commits since the feature branch diverged, so Git just moves the pointer forward.
Question 5: Which Git command is used to temporarily save uncommitted changes without committing them?
- git cache
- git hold
- git stash (Correct answer)
- git save
Correct answer: git stash
'git stash' stores your working directory changes and staged snapshot so you can switch context and reapply later.
Question 6: What is the purpose of a '.gitignore' file in a DevOps project?
- To list files that should be deleted during deployment
- To specify files and directories Git should not track (Correct answer)
- To define merge conflict resolution rules
- To configure Git hooks for CI/CD pipelines
Correct answer: To specify files and directories Git should not track
'.gitignore' tells Git which files or directories to exclude from version control, such as build artifacts, secrets, or dependencies.
Question 7: What is a Git 'tag' primarily used for in a DevOps release workflow?
- To assign work items to specific commits
- To mark specific commits as release points with a version label (Correct answer)
- To protect branches from direct pushes
- To trigger automated CI/CD pipelines
Correct answer: To mark specific commits as release points with a version label
Git tags create named, immutable references to specific commits, making it easy to identify and retrieve exact release versions.
Which Git branching strategy uses long-lived branches named 'main', 'develop', 'release', and 'hotfix'?