AZ-400 Question 5
Select 2Your team has decided to adopt GitHub Flow to streamline feature development and ensure that your main branch is always in a deployable state. You want to enforce consistent workflows that both encourage collaboration and safeguard production-ready code. Which two actions should be included to align with GitHub Flow best practices?
- A
Create a dedicated branch from the main branch for each new feature and work exclusively within that branch.
- B
Merge the feature branch into the main branch via a Pull Request that includes code reviews before merging.
- C
Force-push all feature branches directly to the main branch to keep commits linear and minimize merge commits.
- D
Use a rebase-and-merge approach without requiring any peer review to reduce overhead in merging.
Show answer and explanation
Correct answers: A, B
Explanation
Under GitHub Flow, every feature or fix should be developed in its own branch, undergo code reviews via Pull Requests, and only then be merged into main. This approach ensures a clean commit history, fosters collaboration, and maintains production-ready code. For more information, refer to the official GitHub documentation on GitHub Flow best practices.
- A. Correct.
Option A is correct. Creating a dedicated branch for each feature is a core principle of GitHub Flow, ensuring that work is isolated and can be independently tested or reviewed.
- B. Correct.
Option B is correct. GitHub Flow recommends using Pull Requests with peer reviews before merging to catch issues early and maintain code quality in main.
- C. Incorrect.
Option C is incorrect. Force-pushing directly to main bypasses the collaborative review process and can overwrite others� work, defeating a key objective of GitHub Flow.
- D. Incorrect.
Option D is incorrect. Skipping code reviews removes critical checks. Although rebase-and-merge is a valid merge strategy, omitting peer review goes against best practices.