Merging Pull Requests
What
Merging a Pull Request on GitHub integrates the feature branch’s changes into the remote main branch. Once merged, you must perform local housekeeping to synchronize your local workstation and clean up obsolete pointers.
How
The complete post-merge synchronization cycle consists of:
- Merge & Prune Remotely: Click the “Merge Pull Request” button on GitHub’s interface, and delete the remote branch when prompted to keep remote branches tidy.
- Switch Locally: Switch your local command-line active working directory back to your main branch:
git switch main - Pull Synchronize: Retrieve the newly merged remote commits and synchronize your local
mainbranch:git pull origin main # Output: Fast-forward (Downloads the merge commits and matches your local main with remote main) - Delete Locally: Clean up your workspace by deleting your local feature branch pointer:
git branch -d add_classics
Why
Merging a Pull Request only updates the repository hosted in the cloud (on GitHub’s servers). Your local computer’s main branch does not know about the merge until you explicitly pull the updates. Following up the merge with a git pull and a branch deletion keeps your workspace updated, matches your local history with the remote source of truth, and prunes old branch pointers.
Summary
After merging a Pull Request on GitHub, switch to your local base branch, pull updates using git pull origin <branch_name>, and delete the obsolete local branch using git branch -d.