⚠ Warning:

Any uncommitted local change to tracked files will be lost, even if staged.

But any local file that's not tracked by Git will not be affected.


First, update all origin/<branch> refs to latest:

git fetch --all

Backup your current branch (e.g. main):

git branch backup-main

Jump to the latest commit on origin/main and checkout those files:

git reset --hard origin/main

Explanation:

git fetch downloads the latest from remote without trying to merge or rebase anything.

git reset resets the master branch to what you just fetched. The --hard option changes all the files in your working tree to match the files in origin/main.


Maintain current local commits

[*]: It's worth noting that it is possible to maintain current local commits by creating a branch from main before resetting:

git checkout main
git branch new-branch-to-save-current-commits
git fetch --all
git reset --hard origin/main

After this, all of the old commits will be kept in new-branch-to-save-current-commits.

Uncommitted changes

Uncommitted changes, even if staged (with git add), will be lost. Make sure to stash or commit anything you need. For example, run the following:

git stash

And later (after git reset), reapply these uncommitted changes:

git stash pop

Which may create merge conflicts.

Answer from RNA on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › git › git-pull-force
Git Pull Force - GeeksforGeeks
August 26, 2024 - If there are conflicts between your local changes and the fetched changes, Git prompts you to resolve them manually. A “force pull” refers to forcefully updating your local branch with the remote branch, disregarding any local changes.
People also ask

How do I force git pull to overwrite local files?
There is no single git pull --force command; to forcibly overwrite your local branch with the remote state, you use a two-step approach: first fetch, then hard-reset. Run git fetch origin to download the latest remote state, then git reset --hard origin/ to move your local branch pointer to exactly match the remote, discarding all local commits and staged changes. If you also have untracked files you want to remove, follow up with git clean -fd to delete them — note this is permanent and cannot be undone. Before executing these destructive commands, run git status and git stash push to preserv
🌐
git-tower.com
git-tower.com › learn › git faq › how do i force git pull to overwrite local files?
How do I force git pull to overwrite local files? | Learn Version ...
I used git stash but now I'm getting merge conflicts. Help!
Merge conflicts can occur when reapplying stashed changes on top of new commits. You'll need to resolve the conflicts manually, then `git add` and `git commit` to finish applying the stash.
🌐
blog.openreplay.com
blog.openreplay.com › openreplay blog › git force pull: how to safely overwrite local changes and sync with remote
Git Force Pull: How to Safely Overwrite Local Changes and Sync ...
How do I undo a git reset --hard?
You can usually recover from an accidental `git reset --hard` using `git reflog` to find the commit you were on before the reset, then `git reset --hard ` to that commit hash.
🌐
blog.openreplay.com
blog.openreplay.com › openreplay blog › git force pull: how to safely overwrite local changes and sync with remote
Git Force Pull: How to Safely Overwrite Local Changes and Sync ...
🌐
Codecademy
codecademy.com › article › force-git-pull
How to Force Git Pull to Overwrite Local Changes in Git | Codecademy
Learn how to force `git pull` in Git to overwrite local changes safely using `git reset --hard` and `git stash`. Understand use cases, risks, and best practices.
🌐
ITsyndicate
itsyndicate.org › blog › how-to-use-git-force-pull-properly
Git Pull Force to Overwrite Local Changes - Right Way
So user2 pulls changes and runs into a problem: ... At this stage, if you check the history of user2's workspace, you see that user2 has the following log: ... The conflict can be manually resolved. But user2 decides to get rid of the local changes and start from where user1 left off. The following method is the most effective way to force git pull:
🌐
GitProtect.io
gitprotect.io › strona główna › how to use git pull force to overwrite local files
How to Use Git Pull Force to Overwrite Local Files - Blog | GitProtect.io
September 17, 2024 - So how to force git pull? To make it short, you can force git repo to pull data from some remote repository by fetching data from it and then resetting changes to the branch.
🌐
OpenReplay
blog.openreplay.com › openreplay blog › git force pull: how to safely overwrite local changes and sync with remote
Git Force Pull: How to Safely Overwrite Local Changes and Sync with Remote
February 10, 2025 - While git pull --force may sound like the right command, it’s better to use git fetch and git reset --hard to overwrite local changes and sync with the remote repo. Just be careful, as reset --hard and clean -fd are irreversible! When in doubt, backup your local work with git branch or git stash before resetting.
🌐
freeCodeCamp
freecodecamp.org › news › git-pull-force-how-to-overwrite-local-changes-with-git
Git Pull Force – How to Overwrite Local Changes With Git
July 20, 2020 - Just like git push --force allows overwriting remote branches, git fetch --force (or git pull --force) allows overwriting local branches. It is always used with source and destination branches mentioned as parameters.
Find elsewhere
🌐
GitKraken
gitkraken.com › home › learn › problems & solutions › git pull force
Git Pull Force | GitKraken
August 5, 2022 - The Git pull command allows you to fetch from and integrate with another repo or local branch. There may come a time in your workflow when you wish to forcefully override your local branch’s history and files to match your remote.
🌐
Career Karma
careerkarma.com › blog › git › git: force pull
Git: Force Pull: A Step-By-Step Guide | Career Karma
December 1, 2023 - Git prevents you from pulling files to your local machine if any unsaved or untracked changes would be overwritten by the merge operation. You can use the force pull method to force Git to pull the changes you want to receive on your local computer.
🌐
Git Tower
git-tower.com › learn › git faq › how do i force git pull to overwrite local files?
How do I force git pull to overwrite local files? | Learn Version Control with Git
4 days ago - Force a git pull to overwrite local files: Stash or discard changes & untracked files, then pull. Avoid conflicts with Tower's auto-stashing!
🌐
LoginRadius
loginradius.com › home
How to Perform a Git Force Pull
February 24, 2026 - it feels like it would help to overwrite local changes. instead, it fetches forcefully but does not merge forcefully (git pull --force = git fetch --force + git merge).
🌐
DataCamp
datacamp.com › tutorial › git-pull-force
Git Pull Force: How to Overwrite a Local Branch With Remote | DataCamp
August 6, 2024 - In certain situations, we may wish to reset the state of a local Git branch to align it with the remote repository, thereby discarding any local changes. This is commonly referred to as a forced pull.
🌐
Moon Technolabs
moontechnolabs.com › qanda › git-force-pull
How to Git Force Pull Safely Without Losing Data?
March 26, 2025 - Git Force Pull is a command used to overwrite local changes and sync the repository with the remote version.
🌐
Scaler
scaler.com › home › topics › git › git pull force
Git Pull Force - Scaler Topics
May 4, 2023 - The Git pull force technique allows you to update your local repository with the latest changes of the remote repo even if you have some leftover uncommitted commits local. This force-pulling concept is different from the normal Git pull process. Because in the usual git pull process, you can ...
🌐
GoLinuxCloud
golinuxcloud.com › home › devops › git › git pull force explained: safely overwrite local changes (step-by-step)
Git Pull Force Explained: Safely Overwrite Local Changes (Step-by-Step) | GoLinuxCloud
March 22, 2026 - When someone force pushes to a remote branch, the commit history is rewritten. This causes your local branch to go out of sync, and a normal git pull may fail because Git cannot merge incompatible histories using git merge.
🌐
FlatCoding
flatcoding.com › home › git pull force: safely overwrite local changes
Git Pull Force: Safely Overwrite Local Changes - FlatCoding
March 30, 2025 - Using git pull --force is like saying, “I don’t care about any of this—just give me the latest version and get rid of anything in the way.” You’re telling Git to update your local files with whatever is on the remote when you invoke that command; it has no questions.
🌐
Datree
datree.io › resources › git-force-pull
Git Force Pull Tutorial - Datree.io | Datree.io
For the Googlers: there’s no such thing as `git force pull` - instead, you want to run these two commands: git stash and git pull.
🌐
Better Stack
betterstack.com › community › questions › how-to-force-git-pull
How Do I Force “Git Pull” to Overwrite Local Files? | Better Stack Community
To force git pull to overwrite local files, you can use the git reset command along with the --hard option after pulling changes.
🌐
Peterdaugaardrasmussen
peterdaugaardrasmussen.com › 2023 › 03 › 03 › how-to-force-a-git-pull
Git - How to force a git pull and overwrite local changes
March 4, 2023 - In this scenario we do not care for our own local changes, we just want what is on remote. If we wanted to merge the changes we would commit and pull, but for overwriting we will instead use the following commands: git fetch origin master git reset --hard origin/master
🌐
LabEx
labex.io › tutorials › git-mastering-git-force-pull-390334
Mastering Git Force Pull | LabEx
Git force pull is a powerful yet risky command that can be used to overwrite a local repository with the content from a remote repository.