⚠ 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
🌐
Codecademy
codecademy.com › article › force-git-pull
How to Force Git Pull to Overwrite Local Changes in Git | Codecademy
Use git stash for safety: If we’re ... forced git pull. Understand the consequences: Forcing a git pull (especially with git reset --hard) can overwrite local changes permanently....
Discussions

Does git pull not overwrite local code always?
What you're missing is that the files you edited did not have any changes, because the other devs didn't change those files. There cannot be a conflict on a file if only one person edited the file. Technically git tracks these changes No, it doesn't. When you do e.g. git diff, only then does Git calculate the diff. It doesn't "store" or "follow" the changes in any way; Git only actually records your changes when you add them. More on reddit.com
🌐 r/git
11
4
December 12, 2019
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 overwrite local changes from remote repository?
I don't believe there is a way to do this with 1 command, there is no option for clone that allows it to override existing files. You could have a script that force pulls if the local repo exists and clones if it doesn't. More on reddit.com
🌐 r/git
5
8
March 11, 2022
git pull not working (local files are not being overwritten)

How can I solve this?

By reading the message.

More on reddit.com
🌐 r/git
8
0
August 7, 2018
🌐
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 - Force a git pull to overwrite local files: Stash or discard changes & untracked files, then pull. Avoid conflicts with Tower's auto-stashing!
🌐
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 - When such an operation modifies ... git push --force allows overwriting remote branches, git fetch --force (or git pull --force) allows overwriting local branches....
🌐
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.
🌐
Graphite
graphite.com › guides › git-pull-overwrite-local-changes
How to overwrite local changes when executing a git pull command
Learn how to manage and overwrite local changes during a Git pull operation, including scenarios when you want to keep or discard local modifications.
Find elsewhere
🌐
DataCamp
datacamp.com › tutorial › git-pull-force
Git Pull Force: How to Overwrite a Local Branch With Remote | DataCamp
August 6, 2024 - Therefore, it attempts to merge the local changes with the remote changes, not overwriting them. The correct way to overwrite local changes with the contents of the remote repository is: ... The git reset command must be used with caution because it will delete local changes, even if they have ...
🌐
Fjolt
fjolt.com › article › git-force-overwrite-with-git-pull
How to force overwrite local changes with 'git pull'
You can see all other branches available to switch to by running git branch --list. Finally, we use git reset --hard origin/master to force git pull. This will force overwrite any local changes you made.
🌐
Sentry
sentry.io › sentry answers › git › force `git pull` to overwrite local files
Force `git pull` to overwrite local files | Sentry
How do I force git pull to execute anyway? The simplest and safest way to do this is by using git stash. This command will save and store changes made to a repository’s working directory since the most recent commit and return ...
🌐
Lineserve
lineserve.net › home › blog › how to force git pull to overwrite local files: complete step-by-step guide
How to Force Git Pull to Overwrite Local Files: Complete Step-by-Step Guide — Lineserve Blog
December 11, 2025 - Technically, there’s no direct git pull --force command, but you can force a pull by combining fetch and reset (as in Method 1) or use git pull --force-with-lease in some cases. However, force pulling can be risky in collaborative environments because it might overwrite shared work.
🌐
SourceBae
sourcebae.com › home › how to force git pull to overwrite local files [2026 guide]
How to Force Git Pull to Overwrite Local Files [2026 Guide] - SourceBae
February 11, 2026 - You must explicitly use git reset --hard or git pull --force to overwrite local changes. Create a backup branch first: git checkout -b backup, then switch back to main: git checkout main, and finally force pull: git reset --hard origin/main.
🌐
W3docs
w3docs.com › git
How to Force Git Pull to Override Local Files
Let's find out how to force git pull to overwrite your local changes and fully match your local branch to the remote. Firstly, fetch all branches with the git fetch command. The git fetch command downloads commits, files and references from all remotes into the local repository without merging ...
🌐
TecAdmin
tecadmin.net › force-overwrite-local-files-git-pull
How to Force Overwrite Local Files on Git Pull – TecAdmin
April 26, 2025 - The simplest way to force overwrite local files on Git pull is to use the --force option.
🌐
GitHub
gist.github.com › ae83d8b9c058b419ce8b1f055fb34aa1
[Git] Force `git pull` to overwrite local files · GitHub
[Git] Force `git pull` to overwrite local files · Raw · git-reset-hard.md · Important: If you have any local changes, they will be lost. With or without --hard option, any local commits that haven't been pushed will be lost.[*] If you have ...
🌐
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 ...
🌐
freeCodeCamp
freecodecamp.org › news › how-to-override-local-files-with-git-pull
How to Overwrite Local Files with Git Pull
January 19, 2020 - If you feel the need to discard all your local changes and just reset/overwrite everything with a copy from the remote branch, then you should follow this guide. Important: If you have any local changes, they will be lost. With or without --hard option, any local commits that haven’t been pushed will be lost. If you have any files that are not tracked by Git (e.g.
🌐
DEV Community
dev.to › smpnjn › how-to-force-overwrite-local-changes-with-git-pull-p62
How to force overwrite local changes with 'git pull' - DEV Community
September 4, 2022 - You can see all other branches available to switch to by running git branch --list. Finally, we use git reset --hard origin/master to force git pull. This will force overwrite any local changes you made.
🌐
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 - But let’s consider one thing – can git pull overwrite local changes? Well.. not by default. Remember that in the case of a “pull” operation, there are actually two operations – fetch and merge.
🌐
Medium
medium.com › @python-javascript-php-html-css › overriding-local-changes-with-git-pull-f8b94e67c0b6
Git Pull: Prioritizing Local Modifications | by Denis Bélanger
August 24, 2024 - Forcing a ‘git pull’ to overwrite local changes is a powerful approach to ensure that the local repository aligns perfectly with the remote repository. This process involves fetching the latest changes from the remote without trying to merge ...
🌐
Continuously Merging
articles.mergify.com › git-pull-overwrite-local-changes
Git Pull Overwrite Local Changes A Practical Guide
October 30, 2025 - You're telling Git to point your current branch to the exact same commit as the remote main. Once you run this command, your local main is an exact clone of what's on origin. This two-step fetch and reset process is the cleanest, most direct ...