How to pull changes from a remote repository

· Category: Git

Short answer

Run git pull to fetch changes from the remote and merge them into your current branch.

Steps

  1. Pull with merge (default):
git pull origin main
  1. Pull with rebase:
git pull --rebase origin main
  1. Fetch only (no merge):
git fetch origin
  1. Pull a specific branch:
git pull origin feature-branch

Tips

  • Use git pull --rebase to maintain a linear history.
  • git fetch followed by git merge gives you more control.
  • Review fetched changes with git log HEAD..origin/main before merging.

Common issues

  • Merge conflicts on pull: resolve them before continuing.
  • Local uncommitted changes can block pulls; stash or commit first.