GitHub Flow: Short-Lived Feature Branches
A workflow is a team agreement
A Git workflow defines where work begins, how it is reviewed and how it reaches a shared branch. GitHub Flow is a lightweight approach: start from the current default branch, create a focused branch, publish it, open a pull request, review and integrate, then clean up. Git does not enforce the review process by itself. In the garden-notes example Alice updates watering instructions while Bob adds a light note. Each change can be reviewed independently.
Start with a current base
Follow scenario A in lab-fixtures/chapter19-guide.md. The two clones share a local bare repository, not GitHub. Start on clean main, fetch and fast-forward, then create a descriptive branch. In a real team use the authorized remote and check its URL first. A short-lived branch reduces the amount of divergence, but it does not guarantee conflict-free integration.
git switch maingit pull --ff-onlygit switch -c feature/wateringprintf "Water every 3 days\n" > notes.txtgit add -- notes.txtgit commit -m "Clarify watering interval"git push -u origin feature/wateringReview before integration
In a hosted repository open a PR targeting main. Explain the requirement, scope and checks, and respond to feedback. The offline guide assigns Bob the reviewer role; he fetches the branch, checks the patch and merges it on main as a local analogue, not a real PR. Compare from the merge base using three dots. A green check is evidence of the specific check only. After integration verify that the shared branch contains the expected change.
git fetch origingit diff main...origin/feature/wateringgit show origin/feature/watering:notes.txtClean up deliberately
Fetch integrated main and verify the feature is included. In a merge-commit workflow the original tip is an ancestor of main. Squash integration may preserve the content without that ancestry; do not force deletion just because a PR says merged. Check for dependent work and use the team’s approved cleanup process. Practice: Bob should integrate his light change from current main rather than overwrite Alice’s work.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
GitHub Flow: Short-Lived Feature Branches — knowledge check
Reason about integration cadence, release scope and team policy.
What should a feature branch start from?
What does opening a PR do?
Why keep a feature branch short-lived?
What does the three-dot diff inspect?
After squash integration, what should you verify before deleting a branch?