⚠ 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 - This command directly resets your local branch to match the remote branch, effectively performing a force pull. If you have untracked files or changes in your working directory that you want to discard, use git clean in combination with git reset:
Discussions

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
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
Forgot to switch back to master before creating new feature branch
If you have permissions to force push feature branches: git checkout feature_b git fetch && git rebase origin/master git log origin/master.. # Verify that only 1 commit, "4", is shown git push --force origin feature_b This will rebase the commits in origin/master..feature_b onto latest origin/master. During this, git should recognize that origin/master already has commits with the exact same contents as "1", "2", and "3", and skip them, applying only "4" to the end of origin/master. Force pushing makes origin's version of feature_b match your local one. More on reddit.com
🌐 r/git
10
1
October 20, 2023
Cannot pull from master/origin. How can I fix it?
Why don't you ask your colleagues? Having the courage to ask gives them confidence in your work, asking random reddit users for advice does not. More on reddit.com
🌐 r/git
7
3
September 22, 2023
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 ...
🌐
DataCamp
datacamp.com › tutorial › git-pull-force
Git Pull Force: How to Overwrite a Local Branch With Remote | DataCamp
August 6, 2024 - It uses git merge to merge the local and remote branches. Because of the merge step, git pull isn’t a suitable command in situations where we want to ignore and discard local changes. By looking at the documentation of the git pull command we see that it offers a --force option.
🌐
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 - The last error often appears in VS Code or when switching branches with uncommitted changes. No, git pull does not overwrite local changes. 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.
🌐
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 - Many developers think this command ... actually does something different - it allows you to pull from a remote branch with a divergent history by overwriting your local history....
🌐
Codecademy
codecademy.com › article › force-git-pull
How to Force Git Pull to Overwrite Local Changes in Git | Codecademy
This command fetches the changes from the main branch of the remote origin and merges them into our local main branch. If there are no local changes, this will be a smooth process. However, if we have local changes that conflict with the remote, we may need to perform the operation forcefully. Next, we’ll discover the ideal scenarios where we can force the git pull command.
Find elsewhere
🌐
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.
🌐
Career Karma
careerkarma.com › blog › git › git: force pull
Git: Force Pull: A Step-By-Step Guide | Career Karma
December 1, 2023 - We can force Git to pull the changes by fetching any changes that have been made and then resetting our repository to show those changes. Let’s start by fetching the changes using the git fetch command: ... This command retrieves all of the ...
🌐
Graphite
graphite.com › guides › git-force-pull
Git force pull - Graphite
While git doesn’t actually have a git pull --force command, it’s possible to overwrite your local branch to pull upstream changes, by jumping to the latest commit on origin/main.
🌐
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). Like git push, git fetch allows us to specify which local and remote branch ...
🌐
Scaler
scaler.com › home › topics › git › git pull force
Git Pull Force - Scaler Topics
May 4, 2023 - The command used to pull the changes from a new branch of a remote repo in Git is: 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 ...
🌐
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.
🌐
Git
git-scm.com › docs › git-pull
Git - git-pull Documentation
Integrate changes from a remote repository into the current branch. First, git pull runs git fetch with the same arguments (excluding merge options) to fetch remote branch(es). Then it decides which remote branch to integrate: if you run git pull with no arguments this defaults to the upstream ...
🌐
Reddit
reddit.com › r/learnprogramming › how to perform a git force pull?
r/learnprogramming on Reddit: How to Perform a Git Force Pull?
December 7, 2020 - git reset --hard origin/<branch_name> https://www.loginradius.com/blog/async/git-pull-force/ Legitimate-Reveal573 • · 6y ago · This article has been very helpful. Thanks for sharing :) More replies · My parents don't like me coding. r/learnprogramming • ·
🌐
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 - Git doesn’t have a direct ‘git pull –force’ command, but you can achieve a similar effect by using ‘git fetch’ followed by ‘git reset –hard origin/main’ to overwrite a local branch.
🌐
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.
🌐
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. It is helpful when local modifications conflict with the remote branch, preventing a regular pull.
🌐
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. The other commands are to ensure you don’t lose any data, by making a backup! First, git fetch --all syncs up our remote to our local.
🌐
ITsyndicate
itsyndicate.org › blog › how-to-use-git-force-pull-properly
Git Pull Force to Overwrite Local Changes - Right Way
The following method is the most effective way to force git pull: ... (If you are working with branches, use the branch name instead of master branch).
🌐
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: ... Together, these commands will discard your local changes (saving them for later) and replace them with the latest commit from your remote branch.