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
- Pull with merge (default):
git pull origin main
- Pull with rebase:
git pull --rebase origin main
- Fetch only (no merge):
git fetch origin
- Pull a specific branch:
git pull origin feature-branch
Tips
- Use
git pull --rebaseto maintain a linear history. git fetchfollowed bygit mergegives you more control.- Review fetched changes with
git log HEAD..origin/mainbefore merging.
Common issues
- Merge conflicts on pull: resolve them before continuing.
- Local uncommitted changes can block pulls; stash or commit first.