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:

  1. 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.
  2. Switch Locally: Switch your local command-line active working directory back to your main branch:
    git switch main
  3. Pull Synchronize: Retrieve the newly merged remote commits and synchronize your local main branch:
    git pull origin main
    # Output: Fast-forward (Downloads the merge commits and matches your local main with remote main)
  4. 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.