⚠ 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
The git stash command allows us to temporarily save our local changes, apply a force git pull, and then reapply our stashed changes. Let’s say we’re in the middle of coding a feature, but realize our branch is outdated. So, we want to pull the changes from the remote, but we also don’t want to commit our unfinished work.
Discussions

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
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
only do "git pull" then suddenly my local ahead 26 commit from master
for now i try to re-installing my git software If you're going to waste your time on that, why not buy a new computer - or a new house? You clearly don't understand git, and yet your thought isn't, "This is something I don't understand about git," but, "Git must somehow have broken itself, because it's really stupid." I don't want to be mean, but it's a bad instinct to immediately try to blame some well-known, very stable program used by millions over yourself. If you want help, you're going to have to give actual information. Try the following commands, and report their results back to us: git branch git log --oneline -10 git remote -v git log --oneline -10 origin/master (That last line might be wrong depending on what your branches and remotes really are.) More on reddit.com
🌐 r/git
3
0
December 28, 2022
How can I completely delete commits from both local and remote?
Yes. Your solution will work. git reset --hard [commit hash] will wipe everything after that commit. git push -f [origin branchname] Will make your remote like that too. Two precautions to take note of: This will clean out your directory. If you have any files in there that you want that are not part of previous commits you need to get them out. Using a git push -f without specifying origin branchname afterwards has the potential to force push commits on other branches or possibly overwrite your remote master branch if you are on a forked repository and you haven’t pulled in a bit. This can cause you headaches if you have pull requests out or other situations. It is always best to specify the branch name when using the force push. Additionally, take note of the command git reset --soft . This will allow you to revert your commit history in the same fashion as above while leaving the changes in your files as staged files. This is the solution if you don’t want your current commit history but you do want your current file changes. After this command, you can do a plain git reset to unstage these files or a git commit to make a new commit. More on reddit.com
🌐 r/git
3
5
May 11, 2020
🌐
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:
🌐
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.
🌐
ITsyndicate
itsyndicate.org › blog › how-to-use-git-force-pull-properly
Git Pull Force to Overwrite Local Changes - Right Way
November 9, 2025 - Now let’s go to the user2 folder and clone the remote repository. git clone /Users/_work/LearnGIT/git_force_pull/repository/myproject.git
🌐
DataCamp
datacamp.com › tutorial › git-pull-force
Git Pull Force: How to Overwrite a Local Branch With Remote | DataCamp
August 6, 2024 - When we provide the --force option to git pull, this option is passed down to git fetch. Thus git pull --force performs the following steps: ... We learned that fetch is used to update the local view of the remote repository.
Find elsewhere
🌐
Better Stack
betterstack.com › community › questions › how-to-force-git-pull
How Do I Force “Git Pull” to Overwrite Local Files? | Better Stack Community
If you want to force overwrite without affecting your local changes, you can use git stash to temporarily stash your changes, perform git pull, and then apply the changes back using git stash pop or git stash apply. ... git pull and git fetch are both Git commands used to update your local repository with changes from a remote repository.
🌐
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 the answer to ‘how to force pull in git?’ is simple – use the “force” parameter at the end of our statement. Additionally, when using ‘git checkout’ to switch branches, be aware that Git will prevent switching if there are ...
🌐
Continuously Merging
articles.mergify.com › git-overwrite-local-branch-with-remote
Git Overwrite Local Branch with Remote Safely
August 26, 2025 - In these moments, the best move is a clean slate. The quickest way to force your local branch to be an exact copy of the remote is by running git fetch origin followed by git reset --hard origin/your-branch-name.
🌐
Scaler
scaler.com › home › topics › git › git pull force
Git Pull Force - Scaler Topics
May 4, 2023 - If there are some uncommitted code ... may want to force overwrite all the local repository code changes on the remote repository. For that, git provides the --force option. Choose from our industry-leading programs designed for career success...
🌐
Reddit
reddit.com › r/git › how to overwrite local changes from remote repository?
r/git on Reddit: How to overwrite local changes from remote repository?
March 11, 2022 -

Basically I want to clone a repository, regardless of whether that repository exists locally or not. If there is a local version I want it overwritten. I don't to synchronise any local changes to the master repo, I want a one directional flow of information from the remote repository to the local one. Seems like it should be straightforward, but I can't find an easy way to do this. My solution is to delete the folder and re-clone it every time I want to update it, but that seems wrong. Is there a command for this? something like git clone -force repositorylink

🌐
Graphite
graphite.com › guides › git-pull-overwrite-local-changes
How to overwrite local changes when executing a git pull command
The standard git pull command acts only on the currently checked-out branch, fetching and integrating remote changes specifically into that branch. This means if you maintain multiple dependent or stacked branches, you must manually repeat this ...
🌐
DataCamp
datacamp.com › tutorial › git-push-force
Git Push Force: How it Works and How to Use it Safely | DataCamp
July 24, 2025 - Now, your teammate wastes time untangling the branch, and deployment is delayed. One force push triggers all of that. To avoid such issues, I recommend using git push --force-with-lease. This command adds a safety check when pushing to a remote branch to avoid unexpected commits.
🌐
LoginRadius
loginradius.com › home
How to Perform a Git Force Pull
February 24, 2026 - -----------(or)--------------- ... instead, it fetches forcefully but does not merge forcefully (git pull --force = git fetch --force + git merge)....
🌐
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 ...
🌐
Better Stack
betterstack.com › community › questions › how-to-properly-force-git-push
How Do I Properly Force a Git Push? | Better Stack Community
To force a Git push, you typically use the -f or --force option with the git push command. This is useful when you need to overwrite remote changes that conflict with your local repository or when you need to update a branch that has diverged ...
🌐
Git
git-scm.com › docs › git-worktree
Git - git-worktree Documentation
In the event the repository has a remote and --guess-remote is used, but no remote or local branches exist, then the command fails with a warning reminding the user to fetch from their remote first (or override by using -f/--force).
🌐
WWW Creators
www-creators.com › www creators › dev blog › git › how to force “git pull” to overwrite a local branch?
How to force “git pull” to overwrite a local branch? | WWW Creators
February 21, 2018 - The questions is, “is it possible to FORCE the execution of git pull?” · OK, here’s the answer first: Yes, it is. But there’s not an option like “git pul --force”. So, check out the command below. Be sure you are on your local master branch before the execution.
🌐
Namehero
namehero.com › blog › how-to-use-git-to-push-to-a-different-remote-branch
How to Use Git to Push to a Different Remote Branch
October 24, 2024 - The way to create a pull request depends on the version control manager. For example, you can create a pull request on GitHub once you’ve finished working on the feature for which you created a new remote branch.