A Feature Branch From Start to Finish

Branch, commit, push, review, merge, clean up, sync. The complete real lifecycle, with no shortcuts.

A real pantry checklist needs writing. This lesson performs the entire real lifecycle a disciplined feature branch workflow requires: sync master first, branch, commit in genuinely separate, meaningful steps, push, get it reviewed, merge it in a way that leaves a real record of the merge, then clean up immediately — both the local and the remote copy of the branch.\n\nReal teams that skip the cleanup step accumulate exactly the mess Lesson 2.2.4 will clean up later. Doing it right the first time, every time, is the actual discipline this block is about.

Starting From a Synced master

git switch master
git pull

Real discipline starts here — never branch from a master that might already be behind.

Real, Separate Commits

git switch -c feature/pantry-checklist
# ... three genuinely separate commits ...
git push -u origin feature/pantry-checklist

Three commits, each describing exactly what it added — not one lump "add checklist" commit.

Merging With --no-ff

git switch master
git merge --no-ff feature/pantry-checklist -m "Merge pull request: pantry checklist"
git push

--no-ff forces a real merge commit even when a fast-forward would have been possible — a genuine, permanent record that this feature was reviewed and merged as a deliberate event, not silently absorbed into master's linear history.

Cleaning Up Immediately

git branch -d feature/pantry-checklist
git push origin --delete feature/pantry-checklist

Both copies, gone the moment the feature is safely merged — no stale branch left for anyone to wonder about later.

git merge --no-ff

Forces a real merge commit even when the branch could otherwise fast-forward cleanly. Confirmed directly in this lab: "Merge made by the 'ort' strategy" appeared even though a fast-forward was technically possible, leaving a permanent, real record of when this feature was integrated.

git push origin --delete <branch>

Removes a branch from the remote entirely — the real remote counterpart to git branch -d for a local branch. Confirmed directly in this lab producing a real "[deleted]" line in the push output.

🔄 Sync Master Before Starting

Make sure master is genuinely caught up before branching off it.

cd ~/team-recipes && git switch master
cd ~/team-recipes && git pull

student@lab:~$ cd ~/team-recipes && git switch master Already on 'master' Your branch is behind 'origin/master' by 2 commits, and can be fast-forwarded. (use "git pull" to update your local branch) student@lab:~$ cd ~/team-recipes && git pull Updating d891fe9..c09803f Fast-forward smoothie.md | 3 +++ trail-mix.md | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 smoothie.md create mode 100644 trail-mix.md

📝 Branch and Make Three Real, Separate Commits

Create the feature branch and build the checklist across three genuinely distinct commits.

cd ~/team-recipes && git switch -c feature/pantry-checklist
cd ~/team-recipes && printf 'Pantry Checklist\n\nStaples to always keep on hand.\n' > pantry-checklist.md
cd ~/team-recipes && git add pantry-checklist.md
cd ~/team-recipes && git commit -m 'Start pantry checklist'
cd ~/team-recipes && printf '\n- Flour\n- Sugar\n- Salt\n- Olive oil\n' >> pantry-checklist.md
cd ~/team-recipes && git add pantry-checklist.md
cd ~/team-recipes && git commit -m 'Add basic staples to pantry checklist'
cd ~/team-recipes && printf '\n- Canned tomatoes\n- Dried pasta\n- Rice\n' >> pantry-checklist.md
cd ~/team-recipes && git add pantry-checklist.md
cd ~/team-recipes && git commit -m 'Add pantry checklist items for quick meals'
cd ~/team-recipes && git push -u origin feature/pantry-checklist

student@lab:~$ cd ~/team-recipes && git switch -c feature/pantry-checklist Switched to a new branch 'feature/pantry-checklist' student@lab:~$ cd ~/team-recipes && printf 'Pantry Checklist\n\nStaples to always keep on hand.\n' > pantry-checklist.md student@lab:~$ cd ~/team-recipes && git add pantry-checklist.md student@lab:~$ cd ~/team-recipes && git commit -m 'Start pantry checklist' [feature/pantry-checklist ab1a897] Start pantry checklist 1 file changed, 3 insertions(+) create mode 100644 pantry-checklist.md student@lab:~$ cd ~/team-recipes && printf '\n- Flour\n- Sugar\n- Salt\n- Olive oil\n' >> pantry-checklist.md student@lab:~$ cd ~/team-recipes && git add pantry-checklist.md student@lab:~$ cd ~/team-recipes && git commit -m 'Add basic staples to pantry checklist' [feature/pantry-checklist 1995fa1] Add basic staples to pantry checklist 1 file changed, 5 insertions(+) student@lab:~$ cd ~/team-recipes && printf '\n- Canned tomatoes\n- Dried pasta\n- Rice\n' >> pantry-checklist.md student@lab:~$ cd ~/team-recipes && git add pantry-checklist.md student@lab:~$ cd ~/team-recipes && git commit -m 'Add pantry checklist items for quick meals' [feature/pantry-checklist 07a78da] Add pantry checklist items for quick meals 1 file changed, 4 insertions(+) student@lab:~$ cd ~/team-recipes && git push -u origin feature/pantry-checklist Enumerating objects: 10, done. Counting objects: 100% (10/10), done. Compressing objects: 100% (9/9), done. Writing objects: 100% (9/9), 923 bytes | 71.00 KiB/s, done. Total 9 (delta 5), reused 0 (delta 0), pack-reused 0 To ../recipes-origin.git * [new branch] feature/pantry-checklist -> feature/pantry-checklist branch 'feature/pantry-checklist' set up to track 'origin/feature/pantry-checklist'.

🔗 Merge It In, Leaving a Real Record

After review, merge with --no-ff so the integration itself is permanently visible in history.

cd ~/team-recipes && git switch master
cd ~/team-recipes && git merge --no-ff feature/pantry-checklist -m 'Merge pull request: pantry checklist'
cd ~/team-recipes && git push

student@lab:~$ cd ~/team-recipes && git switch master Switched to branch 'master' Your branch is up to date with 'origin/master'. student@lab:~$ cd ~/team-recipes && git merge --no-ff feature/pantry-checklist -m 'Merge pull request: pantry checklist' Merge made by the 'ort' strategy. pantry-checklist.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 pantry-checklist.md student@lab:~$ cd ~/team-recipes && git push Enumerating objects: 1, done. Counting objects: 100% (1/1), done. Writing objects: 100% (1/1), 228 bytes | 76.00 KiB/s, done. Total 1 (delta 0), reused 0 (delta 0), pack-reused 0 To ../recipes-origin.git c09803f..83fb2bb master -> master

🗑️ Clean Up Both Copies Immediately

Delete the branch locally and on the remote, and confirm the real, final state.

cd ~/team-recipes && git branch -d feature/pantry-checklist
cd ~/team-recipes && git push origin --delete feature/pantry-checklist
cd ~/team-recipes && git log --oneline -5

student@lab:~$ cd ~/team-recipes && git branch -d feature/pantry-checklist Deleted branch feature/pantry-checklist (was 07a78da). student@lab:~$ cd ~/team-recipes && git push origin --delete feature/pantry-checklist To ../recipes-origin.git - [deleted] feature/pantry-checklist student@lab:~$ cd ~/team-recipes && git log --oneline -5 83fb2bb (HEAD -> master, origin/master, origin/HEAD) Merge pull request: pantry checklist 07a78da Add pantry checklist items for quick meals 1995fa1 Add basic staples to pantry checklist ab1a897 Start pantry checklist c09803f Add trail mix recipe

Lab 2.2.1 complete. The full, real feature branch lifecycle, with no shortcuts taken anywhere:\n\n\n Master synced first : ✅ real fast-forward\n Three real commits, pushed : ✅ confirmed\n Merged with --no-ff : ✅ real merge commit\n Both branches cleaned up : ✅ local + remote gone\n

Enable JavaScript to run the live terminal and track your progress.