200-901 Question 29
Single answerA development team is working on a project that involves multiple concurrent feature updates to a shared codebase. They want to ensure that each feature can be developed independently without affecting the main branch until the features are ready for integration. Which Git branching practice should they follow?
- A
Work directly on the main branch and commit changes as they are developed.
- B
Create a feature branch for each new feature and merge it back to the main branch when the feature is complete.
- C
Use a single branch for all features and coordinate commits among team members.
- D
Create a new repository for each feature and merge repositories once the features are complete.
Show answer and explanation
Correct answer: B
Explanation
The correct Git branching practice for concurrent feature development is to create a separate feature branch for each new feature. This allows developers to work independently without affecting the shared codebase in the main branch. Once a feature is complete, it can be merged back into the main branch after review and testing, ensuring stability and easier collaboration.
- A. Incorrect.
Working directly on the main branch increases the risk of introducing bugs or unstable code into the main branch, as all changes are immediately applied to the shared codebase. This approach is not suitable for concurrent development.
- B. Correct.
Creating a feature branch for each new feature ensures that each feature is developed in isolation, reducing conflicts and protecting the stability of the main branch. Once the feature is complete and tested, it can be merged back into the main branch.
- C. Incorrect.
Using a single branch for all features can lead to confusion and conflicts during development, as multiple team members work on the same branch simultaneously. This approach is not recommended for managing concurrent feature development.
- D. Incorrect.
Creating a new repository for each feature is not a practical solution. This approach can make it difficult to manage and integrate changes, as repositories are meant for separate projects rather than individual features.