# if you’re on the branch you want to update (e.g. main or master):
git pull
If your default branch is named something other than “main” (e.g. master or develop), you can be explicit:
git pull origin main
# or
git pull origin master
2. Fetch first, then merge or rebase
Sometimes you want to inspect changes before merging:
git fetch # grabs all new commits from origin
git log HEAD..origin/main # see what’s new
git merge origin/main # integrate upstream changes
# —or—
git rebase origin/main # replay your commits on top of upstream
3. Stashing local tweaks 🧹
If you’ve got uncommitted work but still need to pull:
git stash # tuck away local edits
git pull # now safely pull upstream
git stash pop # re-apply your changes
4. Fetch & prune all branches
If you track multiple remote branches and want to clean up deleted ones:
git fetch --all --prune
5. Hard-reset to match remote (DANGER: destroys local commits)
Use this only if you want your local branch to exactly match the remote, discarding any diverging commits:
git fetch
git reset --hard origin/main
6. Submodules? Don’t forget them 🔗
If your project uses submodules, after pulling:
git submodule update --init --recursive
Quick Workflow Recap
git status – see where you stand
git pull – auto-update your current branch
(Optional) git stash/pop if you had uncommitted changes
git fetch --all --prune for a full cleanup
That’s it! Your clone should now be up to date with the remote repository. 🎉