Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is trunk-based development?
Trunk-based development is a way to work on code where everyone adds their changes directly to one main branch called the trunk or main branch. This helps keep the code simple and up to date.
Click to reveal answer
beginner
Why do teams prefer trunk-based development?
Teams like trunk-based development because it reduces conflicts, makes testing easier, and helps deliver new features faster by keeping all work in one main branch.
Click to reveal answer
intermediate
What is a short-lived feature branch in trunk-based development?
A short-lived feature branch is a small branch created for a quick change or feature. It is merged back into the trunk quickly to avoid long delays and conflicts.
Click to reveal answer
intermediate
How does continuous integration relate to trunk-based development?
Continuous integration means automatically testing and merging code often. It works well with trunk-based development because changes are small and frequent, making problems easier to find and fix.
Click to reveal answer
beginner
What is a common risk if trunk-based development is not followed properly?
If trunk-based development is not followed, big conflicts can happen, code can break often, and it becomes hard to deliver updates quickly.
Click to reveal answer
In trunk-based development, where do developers usually commit their changes?
ADirectly to the main trunk branch
BTo long-lived feature branches
COnly to release branches
DTo personal forks only
✗ Incorrect
In trunk-based development, developers commit directly to the main trunk branch or very short-lived branches merged quickly.
What is a key benefit of trunk-based development?
AUses many long-lived branches
BAvoids merge conflicts by merging often
CRequires no testing
DKeeps features hidden for months
✗ Incorrect
Merging often in trunk-based development helps avoid big merge conflicts.
Which practice supports trunk-based development best?
ANo code reviews
BManual testing after release
CContinuous integration with automated tests
DWorking in isolation for weeks
✗ Incorrect
Continuous integration with automated tests helps catch problems early in trunk-based development.
How long should feature branches be kept in trunk-based development?
ASeveral months
BOnly after release
CNever merged
DVery short-lived, merged quickly
✗ Incorrect
Feature branches should be short-lived and merged quickly to keep the trunk updated.
What happens if many developers work on long-lived branches instead of trunk?
AMore merge conflicts and delays
BFaster delivery
CSimpler codebase
DNo need for testing
✗ Incorrect
Long-lived branches increase merge conflicts and slow down delivery.
Explain trunk-based development and why it helps teams deliver software faster.
Think about how working together on one main branch can make things simpler.
You got /4 concepts.
Describe how continuous integration supports trunk-based development.
Consider how testing often helps keep the main branch healthy.
You got /4 concepts.
Practice
(1/5)
1. What is the main idea behind trunk-based development?
easy
A. Developing mostly on one main branch to avoid big merge conflicts
B. Creating many long-lived branches for each feature
C. Working only on local branches without pushing to remote
D. Merging branches only once a month
Solution
Step 1: Understand trunk-based development concept
It focuses on working mainly on one main branch, often called trunk or main.
Step 2: Compare options with this concept
Options A, C, and D describe practices that do not align with trunk-based development principles.
Final Answer:
Developing mostly on one main branch to avoid big merge conflicts -> Option A
Quick Check:
Trunk-based development = one main branch [OK]
Hint: Remember: trunk means main branch work mostly [OK]
Common Mistakes:
Thinking trunk means many long-lived branches
Believing merges happen rarely in trunk-based
Confusing local-only work with trunk-based
2. Which of the following git commands is best to quickly merge a short-lived feature branch back to main in trunk-based development?
easy
A. git merge feature-branch
B. git rebase feature-branch
C. git checkout feature-branch
D. git branch -d feature-branch
Solution
Step 1: Identify the command to merge branches
git merge feature-branch merges the feature branch into the current branch, usually main.
Step 2: Check other commands
git rebase rewrites history, git checkout switches branches, and git branch -d deletes a branch but does not merge.
Final Answer:
git merge feature-branch -> Option A
Quick Check:
Merge short-lived branch = git merge [OK]
Hint: Merge feature branch with git merge [OK]
Common Mistakes:
Using git checkout instead of merging
Deleting branch before merging
Confusing rebase with merge
3. Given this sequence of commands in trunk-based development:
git checkout main
git pull origin main
git checkout -b feature
# make changes
git commit -am 'Add feature'
git checkout main
git merge feature
What is the state of the main branch after these commands?
medium
A. Main branch is unchanged and does not have feature changes
B. Main branch has the new feature changes merged in
C. Feature branch is deleted automatically
D. Main branch is behind origin/main
Solution
Step 1: Follow the commands step-by-step
Start on main, update it from origin, create feature branch, commit changes, switch back to main, then merge feature into main.
Step 2: Understand merge effect
After merge, main branch includes the feature changes locally.
Final Answer:
Main branch has the new feature changes merged in -> Option B
Quick Check:
Merge feature into main = main updated [OK]
Hint: Merge updates main branch with feature changes [OK]
5. In trunk-based development, a team wants to avoid long-lived branches but still work on multiple features simultaneously. Which strategy fits best?
hard
A. Work only on main branch without any feature branches
B. Keep all features in one big branch for weeks before merging
C. Use separate repositories for each feature
D. Create short-lived feature branches, merge them quickly to main, and deploy often
Solution
Step 1: Understand trunk-based development goals
It encourages short-lived branches merged quickly to main to reduce conflicts and speed releases.
Step 2: Evaluate options
Create short-lived feature branches, merge them quickly to main, and deploy often matches this approach. Keep all features in one big branch for weeks before merging causes long-lived branches. Work only on main branch without any feature branches limits parallel work. Use separate repositories for each feature complicates repo management.
Final Answer:
Create short-lived feature branches, merge them quickly to main, and deploy often -> Option D
Quick Check:
Short-lived branches + quick merge = trunk-based best practice [OK]
Hint: Use short-lived branches merged fast to main [OK]
Common Mistakes:
Thinking all work must be on main only
Using long-lived branches defeats trunk-based purpose
Splitting features into separate repos unnecessarily