⚠ 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
🌐
Quora
quora.com › How-do-I-force-git-pull-to-overwrite-local-files-1
How to force 'git pull' to overwrite local files - Quora
Answer (1 of 17): You can probably do [code]git stash git stash drop # deletes the latest changes on the stash [/code]However [code ]git reset HEAD —hard[/code] would be the proper way to do what you want. This resets your git workspace to the latest commit on the local branch, and discards ...
Discussions

How to use git pull force to overwrite local files? - Ask a Question - TestMu AI Community
How to use git pull force to overwrite local files? More on community.testmuai.com
🌐 community.testmuai.com
0
May 13, 2024
Rebasing to master branch and git pull are causing issues in CI/CD pipeline. What am I doing wrong?
Only do what git tells you when you know why. Rebasing introduced a discrepancy between your local and remote repo, and for any discrepancy git tells you to pull. If that is right depends on what you want. Also, pulling does a silent merge, which makes everything in your situation worse. (edit: there a setting called pull.ff-only or something, you might want to enable thisr. Is there a reason you rebase instead of merge? Edit: re how to fix: make your local history of feature look like you want to, then force-push. And read up on how rebasing works. More on reddit.com
🌐 r/git
9
3
September 12, 2022
How do I overwrite one branch with another branch?
Why not... make a new branch? More on reddit.com
🌐 r/git
23
42
May 20, 2019
How to Perform a Git Force Pull?
If you just don't give a damn about the changes you've made and just want to pull down what's in your remote (assuming the same branch) you can do the following: git reset --hard && git pull The first command resets the working directory and staging area to the last commit you have for your branch. Then you just pull like normal. If you've made commits that aren't in remote and you want to get rid of those as well, you can do the following, assuming your remote's name is origin git fetch --all && git reset origin/ More on reddit.com
🌐 r/learnprogramming
3
2
December 7, 2020
🌐
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.
🌐
GeeksforGeeks
geeksforgeeks.org › git › git-pull-force
Git Pull Force - GeeksforGeeks
August 26, 2024 - Replace <branch-name> with your branch’s name (e.g., main or master). This command forcefully moves your local branch to match the remote branch, discarding any local commits and changes.
🌐
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
5 days ago - Git will abort the pull and show an error if your uncommitted changes conflict with incoming changes. This is a safety mechanism — your local work remains untouched until you explicitly decide what to do with it. For this reason, there is no "force pull" feature in Git — but you can perform a couple of steps to achieve the same result: force pulling from the remote and overwriting your local files.
Find elsewhere
🌐
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.
🌐
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.
🌐
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.
🌐
ITsyndicate
itsyndicate.org › blog › how-to-use-git-force-pull-properly
Git Pull Force to Overwrite Local Changes - Right Way
So the git force pull has got rid of user2's local changes and reset it to origin master.
🌐
Fjolt
fjolt.com › article › git-force-overwrite-with-git-pull
How to force overwrite local changes with 'git pull'
The key command to force a git pull from a remote repository is git reset --hard origin/master.
🌐
Graphite
graphite.com › guides › git-pull-overwrite-local-changes
How to overwrite local changes when executing a git pull command
After popping the stash, you may need to resolve conflicts between your local changes and the newly pulled changes. The standard git pull command acts only on the currently checked-out branch, fetching and integrating remote changes specifically into that branch.
🌐
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).
🌐
Software House
softwarehouse.au › home › blog › how do i force git pull to overwrite local files
How Do I Force Git Pull to Overwrite Local Files?
March 2, 2026 - Although Git does not have a direct git pull force command, combining fetch and reset achieves the same result. shCopy code# Fetch the latest changes git fetch origin # Reset to the fetched branch git reset --hard origin/master
🌐
Saturn Cloud
saturncloud.io › blog › how-to-force-git-pull-to-overwrite-local-files
How to Force git pull to Overwrite Local Files | Saturn Cloud Blog
May 1, 2026 - However, there are situations where you may want to force “git pull” to overwrite local files without prompting for manual conflict resolution. This can be useful if you know that your local changes are obsolete and you want to replace them with the changes from the remote repository.
🌐
Squash
squash.io › how-to-force-git-pull-to-overwrite-local-files
How to Force Git Pull to Overwrite Local Files
August 20, 2023 - Here's the command to force a Git ... Then, it resets your local copy to match the "origin/master" branch using "git reset --hard origin/master"....
🌐
Flexiple
flexiple.com › git › git-pull-force
Git Pull Force – How to Overwrite Local Changes With Git - Flexiple
Such conflicts occur when multiple developers modify the same lines in a file or when one developer's local changes conflict with incoming updates. Regular Git Pull attempts can fail due to these conflicts, necessitating manual resolution to merge the divergent changes. The concept of "forcing" a pull presents a solution, enabling the override of local modifications with remote repository content.
🌐
Career Karma
careerkarma.com › blog › git › git: force pull
Git: Force Pull: A Step-By-Step Guide | Career Karma
December 1, 2023 - Master’s Degree · Doctoral · ... 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....
🌐
JavaScript in Plain English
javascript.plainenglish.io › how-do-i-force-git-pull-to-overwrite-local-files-cc59b962df82
How Do I Force git pull to Overwrite Local Files? | by M Business Solutions | JavaScript in Plain English
December 4, 2024 - How Do I Force git pull to Overwrite Local Files? “Forcing git pull --force is like using a flamethrower to clean your house—sure, it works, but use it wisely." Imagine you’re in the middle of …