AI Hints
Home›Git & GitHub Tutorial›Project: Hotfix
Git & GitHub · Lesson 132 of 144

Project: Bringing the Fix Home

Merge the hotfix into main.

⏱ 2 min read▶ Video at 2:23:32🎓 Free
Watch this lesson in the Git & GitHub courseWatch on YouTube ↗Full Git & GitHub course

There's one last step people often forget. Main doesn't have the fix yet. If we don't add it, the bug will come back in version one point one.

Project: Bringing the Fix Home
From the video: Project: Bringing the Fix Home
  • main still has the bug
  • Easy to forget
  • It would come back in v1.1

Merge the hotfix

Switch to main, and merge the hotfix branch. Git creates a merge commit, joining the fix with our unfinished shop work. The graph shows both lines. Now every future version will include the fix. Finally, delete the hotfix branch.

git
git switch main
Switched to branch 'main'
Your branch is ahead of 'origin/main' by 1 commit.
  (use "git push" to publish your local commits)
git merge --no-edit hotfix/about-link
Merge made by the 'ort' strategy.
 index.html | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
git log --oneline --graph -n 4
*   a3f0a5e (HEAD -> main) Merge branch 'hotfix/about-link'
|\
| * 05d3c51 (tag: v1.0.1, origin/hotfix/about-link, hotfix/about-link) Fix broken About link
* | 2cb1565 Start shop page (not ready)
|/
* b5a503b (tag: v1.0, origin/main) Tidy home page
git branch -d hotfix/about-link
Deleted branch hotfix/about-link (was 05d3c51).

The hotfix recipe

Here's the whole recipe, to remember. Branch from the release tag. Fix only the bug. Tag a patch version, and release it. Then merge the fix back into main, so it's never lost.

1. Branchfrom the tag
2. Fixonly the bug
3. Releasetag v1.0.1
4. Mergeback into main

Summary

Branch from the tag, fix, tag a patch, then merge back into main. That's how teams fix live bugs safely. Next, getting ready for Git interview questions.

Key takeaways
  • Branch from the tag
  • Tag the patch
  • Merge back to main
Next up: Interview Questions: The Basics — what interviewers ask