Git Workflows in Real Teams: Choosing the Right Approach
A common interview question is: 'Which Git workflow have you used?' After this section, you'll have a thorough and honest answer. We'll examine three popular approaches — Feature Branch Workflow, Git Flow, and Trunk-Based Development — and explore where each one works well and where it might become a bottleneck.
- You'll be able to describe three common Git workflows in interviews and explain their key differences.
- You'll understand how team size and release frequency influence the choice of development process.
- You'll learn to ask the right questions about workflows when joining a new team.
Phần đầu bài giảng
Why Feature Branch Workflow?
- Feature Branch = separate chapter draft
- Code isolation for parallel work
- Safe experimentation without risking main
- Easy to implement for teams of all levels
- Ideal for startups and small projects
Imagine you're working on a book and creating a separate draft for each chapter. That's exactly how the Feature Branch Workflow operates — each new feature lives in an isolated environment. This approach allows teams to work on different tasks simultaneously without creating chaos in the main codebase. You can experiment freely, knowing the main branch remains stable. This is particularly suitable for small teams where speed and flexibility are crucial. When a feature is ready, it undergoes code review before being merged into the main code. The simplicity and efficiency of this approach make it incredibly popular.
Feature Branch Lifecycle
- git checkout -b feature/new-payment
- Commits with clear messages
- git push origin feature/new-payment
- Create pull request
- Code review and merge to main
Let's walk through the entire lifecycle of a feature branch, from creation to merge. We start with the command 'git checkout -b feature/new-payment' — this creates a new branch from main. We work on the task, making commits with clear and detailed descriptions. When the feature is ready, we push the branch to the remote repository and create a pull request. Colleagues review the code, provide feedback, and after addressing all comments, the changes are merged into the main branch. An important rule to remember: one branch per logically complete task. This helps maintain order in the commit history.
# Create branch from main
git checkout main
git pull origin main
git checkout -b feature/new-payment
# Work and commit
echo 'Add payment processing' > payment.js
git add payment.js
git commit -m 'Add payment processing module'
# Push and create PR
git push origin feature/new-payment
# Then create Pull Request via GitHub UI
Creating a Feature Branch in 2 Commands
- Feature Branch Workflow — simple and effective
- Create a branch from the latest main
- git checkout -b feature/new-login
- Branch name reflects the task
- feature/, fix/, docs/ — prefixes for clarity
Let's create a feature branch in practice. First, switch to the main branch and update it: git checkout main double ampersand git pull. Now, create a new branch for our task: git checkout minus b feature slash new-login. The minus b flag tells Git to create a new branch and switch to it immediately. Just two commands — and you're ready to work. Make sure the branch name reflects the task: feature slash, fix slash, or docs slash at the beginning helps quickly understand the branch's purpose. Now you can start making changes.
git checkout main && git pull
# Update the main branch
git checkout -b feature/new-login
# Create and switch to the new branch
Bài giảng đầy đủ dành cho thuê bao
Còn 31 slide nữa trong phiên bản đầy đủ.
Video, toàn bộ slide, ghi chú, bài kiểm tra, gia sư AI và phỏng vấn sẽ mở sau khi đăng nhập và đăng ký thuê bao.
Đăng nhập hoặc đăng ký Đăng ký thuê baoNội dung bài giảng
- Why Feature Branch Workflow?
- Feature Branch Lifecycle
- Creating a Feature Branch in 2 Commands
- Submitting Changes for Review
- Going Through Code Review and Merging
- Git Flow: The Development Pipeline
- Feature Branches and Release Preparation
- Emergency Fixes with Hotfixes
- Practice: Creating a Feature Branch
- Setting Up Git Flow in Your Project
- Feature Development: From Branch to Merge
- Preparing for Release: Packaging Changes
- Emergency Fixes: Hotfixes in Action
- Trunk-Based Development: The Core Concept
- How to Handle Unfinished Features in TBD
- Practice: Frequent Commits to Main
- When to Choose Trunk-Based Development
- Mistake 1: Using Git Flow for Small Teams
- Mistake 2: Trunk-Based Without Code Review
- Mistake 3: Long-Lived Feature Branches
- How to Choose the Right Workflow
- How to Choose a Git Process: Key Criteria
- Feature Branch: The City Car for Startups
- Git Flow: The Off-Roader for Large Teams
- Trunk-Based: The Racing Car for Frequent Releases
- Analysing Your Current Git Process: What's Wrong with Git Flow
- Migration Plan: Moving from a House to a Studio Flat
- Training the Team in New TBD Practices
- Practice: Migrating a Feature Branch to TBD
- How to Discuss Workflow in Job Interviews
- Common Problems and Their Solutions
- Implementing Process Improvements
- What Not to Say in an Interview
- Choosing Your Path: Summary and Homework
Bài viết liên quan đến bài học này
- Git merge và rebase: nên chọn cái nào cho nhóm
- Câu hỏi về Git khi phỏng vấn: 25 câu hỏi và đáp án
- Git Flow, GitHub Flow và trunk-based: chọn quy trình Git nào
- Git và GitHub: khác nhau thế nào và liên hệ ra sao
- Cách cài đặt Git trên Windows, macOS và Linux
Tất cả bài giảng của khóa học
- Introduction: Git from Scratch to Confident Developer
- Why Git is Essential - And Why It's a Job Requirement
- Installation and Setup: Getting Git Ready for First Use
- First Repository: init, add, commit, and the Magic of the Index
- Reading History: log, diff, show and Navigating the Past
- Branches: The Parallel Reality of Your Code
- Undoing Mistakes: restore, reset, revert — Doing It Right and the Dangers
- GitHub and Remote Repositories: Your Code in the Cloud
- Team Collaboration: Forks, Feature Branches, and Pull Requests
- Merge Conflicts: Don't Panic - Understanding and Resolving Them
- Git Workflows in Real Teams: Choosing the Right Approach
- Advanced Tools: Rebase, Stash, Cherry-pick and Tags
- Final Project: Simulating Real Team Development