Review Questions - Git Collaboration Workflow#
Test your understanding of Git concepts and workflows with these review questions.
Multiple Choice#
1. What is the purpose of the staging area in Git?#
A) To store backup copies of files
B) To select which changes to include in the next commit
C) To merge branches automatically
D) To resolve conflicts
Answer
B) To select which changes to include in the next commit
The staging area (index) allows you to selectively choose which changes go into your next commit, giving you fine-grained control over your commit history.
2. In Gitflow, which branch should hotfixes be merged into?#
A) Only
mainB) Only
developC) Both
mainanddevelopD) Only the feature branch
Answer
C) Both main and develop
Hotfixes must be merged into both branches to ensure the fix is deployed to production (main) and also included in ongoing development (develop).
3. What does the --no-ff flag do when merging?#
A) Skips conflict resolution
B) Forces a merge commit even if fast-forward is possible
C) Deletes the source branch after merge
D) Merges without fetching remote changes
Answer
B) Forces a merge commit even if fast-forward is possible
The --no-ff flag creates a merge commit that preserves the history of the feature branch, making it easier to see when features were integrated.
4. Which conventional commit type indicates a breaking change?#
A)
break:B)
feat!:C)
major:D)
breaking:
Answer
B) feat!:
The exclamation mark (!) after the type indicates a breaking change. You can also use a BREAKING CHANGE: footer in the commit body.
5. What command shows the difference between staged and unstaged changes?#
A)
git statusB)
git logC)
git diffD)
git show
Answer
C) git diff
git diffshows unstaged changesgit diff --stagedshows staged changesgit diff HEADshows all changes since last commit
Scenario Questions#
6. Feature Branch Conflict#
You’re working on feature/payment and need to merge it to main. However, a teammate has already merged changes to main that conflict with your code.
What steps should you take?
Answer
Fetch latest changes:
git fetch originRebase or merge main into your branch:
git checkout feature/payment git rebase main # or git merge main
Resolve conflicts in each file (remove conflict markers)
Continue the rebase:
git rebase --continue(or commit if merging)Test your code to ensure the merge didn’t break anything
Push and create PR:
git push origin feature/payment
7. Emergency Hotfix#
Production is down due to a critical bug in version 2.1.0. You need to deploy a fix immediately, but the develop branch has incomplete features.
Which workflow should you use?
Answer
Use the Hotfix workflow:
Create hotfix branch from
main:git checkout -b hotfix/2.1.1 main
Fix the bug and commit:
git commit -m "fix: Resolve critical production issue"
Bump version and merge to
main:git checkout main git merge --no-ff hotfix/2.1.1 git tag -a v2.1.1 -m "Hotfix release"
Merge back to
develop:git checkout develop git merge --no-ff hotfix/2.1.1
Delete hotfix branch and deploy
8. Messy Commit History#
You have 5 commits with messages like “wip”, “fix typo”, “more changes”, “oops”, and “done”. Your team requires clean commit history before merging PRs.
How do you clean this up?
Answer
Use interactive rebase to squash commits:
git rebase -i HEAD~5
In the editor, change all but the first pick to squash:
pick abc1234 wip
squash def5678 fix typo
squash ghi9012 more changes
squash jkl3456 oops
squash mno7890 done
Then write a proper commit message:
feat: Add payment processing module
- Implement payment gateway integration
- Add validation for card details
- Handle error responses
Command Identification#
9. Match the command to its purpose:#
Command |
Purpose |
|---|---|
|
? |
|
? |
|
? |
|
? |
Answer
Command |
Purpose |
|---|---|
|
Temporarily save uncommitted changes |
|
Apply a specific commit to current branch |
|
Discard the last commit and its changes |
|
View history of all Git operations |
10. What commands would you use to:#
Create a new branch and switch to it
See all branches (local and remote)
Delete a merged branch
Rename the current branch
Answer
# 1. Create and switch to new branch
git checkout -b new-branch
# or
git switch -c new-branch
# 2. See all branches
git branch -a
# 3. Delete a merged branch
git branch -d branch-name
# 4. Rename current branch
git branch -m new-name
Short Answer#
11. Explain the difference between git merge and git rebase#
Answer
Git Merge:
Creates a merge commit combining two branches
Preserves complete history of both branches
Non-destructive (doesn’t rewrite history)
Results in a non-linear history
Git Rebase:
Moves commits to begin on top of another branch
Creates a linear, cleaner history
Rewrites commit history (changes SHAs)
Should not be used on shared/public branches
When to use each:
Merge: For merging feature branches to main, preserving context
Rebase: For updating feature branches with latest main changes, cleaning up local commits
12. What makes a good Pull Request?#
Answer
A good Pull Request should have:
Descriptive title summarizing the change
Clear description explaining what, why, and how
Small, focused scope (ideally < 400 lines)
Passing CI/CD checks
Self-review completed before requesting review
Linked issues using keywords like “Closes #123”
Screenshots/recordings for UI changes
No merge conflicts with target branch
Proper testing documented or included
13. Why should you use Conventional Commits?#
Answer
Benefits of Conventional Commits:
Automatic changelog generation - Tools can parse commits to create release notes
Semantic versioning - Commit types determine version bumps:
fix→ PATCHfeat→ MINORBREAKING CHANGE→ MAJOR
Clear communication - Team members understand changes at a glance
Better searchability - Easy to find specific types of changes
CI/CD automation - Trigger different workflows based on commit type
Self-Assessment Checklist#
Rate your confidence (1-5) on each skill:
Skill |
Confidence |
|---|---|
Creating and switching branches |
⬜ |
Staging and committing changes |
⬜ |
Resolving merge conflicts |
⬜ |
Using Gitflow workflow |
⬜ |
Writing conventional commits |
⬜ |
Interactive rebasing |
⬜ |
Creating effective PRs |
⬜ |
Reviewing others’ code |
⬜ |
Scoring:
35-40: Expert level - ready to lead Git workflows
25-34: Proficient - comfortable with daily Git usage
15-24: Intermediate - practice more complex scenarios
Below 15: Beginner - review documentation and redo exercises