Đoạn xem trước bài giảng

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.

Feature Branch Workflow Git Flow Trunk-Based Development
Bạn sẽ học gì trong bài giảng này
  • 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ê bao

Nội dung bài giảng

  1. Why Feature Branch Workflow?
  2. Feature Branch Lifecycle
  3. Creating a Feature Branch in 2 Commands
  4. Submitting Changes for Review
  5. Going Through Code Review and Merging
  6. Git Flow: The Development Pipeline
  7. Feature Branches and Release Preparation
  8. Emergency Fixes with Hotfixes
  9. Practice: Creating a Feature Branch
  10. Setting Up Git Flow in Your Project
  11. Feature Development: From Branch to Merge
  12. Preparing for Release: Packaging Changes
  13. Emergency Fixes: Hotfixes in Action
  14. Trunk-Based Development: The Core Concept
  15. How to Handle Unfinished Features in TBD
  16. Practice: Frequent Commits to Main
  17. When to Choose Trunk-Based Development
  18. Mistake 1: Using Git Flow for Small Teams
  19. Mistake 2: Trunk-Based Without Code Review
  20. Mistake 3: Long-Lived Feature Branches
  21. How to Choose the Right Workflow
  22. How to Choose a Git Process: Key Criteria
  23. Feature Branch: The City Car for Startups
  24. Git Flow: The Off-Roader for Large Teams
  25. Trunk-Based: The Racing Car for Frequent Releases
  26. Analysing Your Current Git Process: What's Wrong with Git Flow
  27. Migration Plan: Moving from a House to a Studio Flat
  28. Training the Team in New TBD Practices
  29. Practice: Migrating a Feature Branch to TBD
  30. How to Discuss Workflow in Job Interviews
  31. Common Problems and Their Solutions
  32. Implementing Process Improvements
  33. What Not to Say in an Interview
  34. Choosing Your Path: Summary and Homework

Bài viết liên quan đến bài học này

Tất cả bài giảng của khóa học

  1. Introduction: Git from Scratch to Confident Developer
  2. Why Git is Essential - And Why It's a Job Requirement
  3. Installation and Setup: Getting Git Ready for First Use
  4. First Repository: init, add, commit, and the Magic of the Index
  5. Reading History: log, diff, show and Navigating the Past
  6. Branches: The Parallel Reality of Your Code
  7. Undoing Mistakes: restore, reset, revert — Doing It Right and the Dangers
  8. GitHub and Remote Repositories: Your Code in the Cloud
  9. Team Collaboration: Forks, Feature Branches, and Pull Requests
  10. Merge Conflicts: Don't Panic - Understanding and Resolving Them
  11. Git Workflows in Real Teams: Choosing the Right Approach
  12. Advanced Tools: Rebase, Stash, Cherry-pick and Tags
  13. Final Project: Simulating Real Team Development