AI Hints
Home›Git & GitHub Tutorial›Merging Pull Requests
Git & GitHub · Lesson 73 of 144

After the Merge

Tidying up.

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

The pull request is merged on GitHub. But your computer doesn't know yet. Your local main is behind, and your old branch is still lying around. Let's tidy up.

After the Merge
From the video: After the Merge
  • Merged on GitHub
  • Your main is behind
  • Old branch still around

Update main

Switch to main, and pull. The merge commit from GitHub, merge pull request number one, arrives. Our main is up to date, and includes the blog.

git
git switch main
Switched to branch 'main'
Your branch is up to date with 'origin/main'.
git pull
From https://github.com/sam/my-site
   f63a17a..c477616  main       -> origin/main
Updating f63a17a..c477616
Fast-forward
 blog.html  | 1 +
 index.html | 1 +
 2 files changed, 2 insertions(+)
 create mode 100644 blog.html
git log --oneline -n 3
c477616 (HEAD -> main, origin/main) Merge pull request #1 from sam/add-blog
a05e8bd (origin/add-blog, add-blog) Link to blog
55c6b9b Add blog page

Delete old branches

Now delete the local branch, with git branch dash d. GitHub usually deletes the remote branch after merging. But your computer still remembers origin slash add blog. Git fetch, dash dash prune, removes remote branches that no longer exist. Git branch dash a shows everything is tidy.

git
git branch -d add-blog
Deleted branch add-blog (was a05e8bd).
git fetch --prune
From https://github.com/sam/my-site
 - [deleted]         (none)     -> origin/add-blog
git branch -a
* main
  remotes/origin/main

Summary

After a merge, switch to main, pull, delete the branch, and prune. Then start the next feature from a fresh main. Next, issues.

Key takeaways
  • git switch main && git pull
  • git branch -d <branch>
  • git fetch --prune
Next up: Issues — tracking work on GitHub