Cheat Sheets · Git Cheat Sheet · Git Force Pull — Overwrite Local Changes with Remote
Git Force Pull — Overwrite Local Changes with Remote
git fetch origin1. Download all latest commits from remote without merging
git reset --hard origin/main2. Force local main branch pointer to match origin/main exactly
git clean -fd3. (Optional) Remove any new untracked local files
Force pull sequence
| Command | Step |
|---|---|
git fetch origin | 1. Download all latest commits from remote without merging |
git reset --hard origin/main | 2. Force local main branch pointer to match origin/main exactly |
git clean -fd | 3. (Optional) Remove any new untracked local files |
When your local branch is hopelessly messed up or you want an exact mirror of the remote repository, reset hard to origin.
Related Git recipes
FAQ
Why doesn't git pull --force exist?
git pull is fetch + merge. Merging cannot simply overwrite uncommitted or divergent work without conflict. Fetch + reset --hard is the explicit solution.
Are my local commits lost?
Unpushed local commits are removed from the branch pointer. You can still recover them via git reflog for up to 90 days.
Can I save my uncommitted work before force pulling?
Yes: run git stash -u before resetting, then apply it later if needed.
Stop memorizing — build it interactively
Build force sync in the Git BuilderFull reference: Git Cheat Sheet