You should be able to force your local revision to the remote repo by using

git push -f <remote> <branch>

(e.g. git push -f origin master). Leaving off <remote> and <branch> will force push all local branches that have set --set-upstream.

Just be warned, if other people are sharing this repository their revision history will conflict with the new one. And if they have any local commits after the point of change they will become invalid.

Update: Thought I would add a side-note. If you are creating changes that others will review, then it's not uncommon to create a branch with those changes and rebase periodically to keep them up-to-date with the main development branch. Just let other developers know this will happen periodically so they'll know what to expect.

Update 2: Because of the increasing number of viewers I'd like to add some additional information on what to do when your upstream does experience a force push.

Say I've cloned your repo and have added a few commits like so:

            D----E  topic
           /
A----B----C         development

But later the development branch is hit with a rebase, which will cause me to receive an error like so when I run git pull:

Unpacking objects: 100% (3/3), done.
From <repo-location>
 * branch            development     -> FETCH_HEAD
Auto-merging <files>
CONFLICT (content): Merge conflict in <locations>
Automatic merge failed; fix conflicts and then commit the result.

Here I could fix the conflicts and commit, but that would leave me with a really ugly commit history:

       C----D----E----F    topic
      /              /
A----B--------------C'  development

It might look enticing to use git pull --force but be careful because that'll leave you with stranded commits:

            D----E   topic

A----B----C'         development

So probably the best option is to do a git pull --rebase. This will require me to resolve any conflicts like before, but for each step instead of committing I'll use git rebase --continue. In the end the commit history will look much better:

            D'---E'  topic
           /
A----B----C'         development

Update 3: You can also use the --force-with-lease option as a "safer" force push, as mentioned by Cupcake in his answer:

Force pushing with a "lease" allows the force push to fail if there are new commits on the remote that you didn't expect (technically, if you haven't fetched them into your remote-tracking branch yet), which is useful if you don't want to accidentally overwrite someone else's commits that you didn't even know about yet, and you just want to overwrite your own:

git push <remote> <branch> --force-with-lease

You can learn more details about how to use --force-with-lease by reading any of the following:

  • git push documentation
  • Git: How to ignore fast forward and revert origin [branch] to earlier commit?
Answer from Trevor Norris on Stack Overflow
Top answer
1 of 6
1506

You should be able to force your local revision to the remote repo by using

git push -f <remote> <branch>

(e.g. git push -f origin master). Leaving off <remote> and <branch> will force push all local branches that have set --set-upstream.

Just be warned, if other people are sharing this repository their revision history will conflict with the new one. And if they have any local commits after the point of change they will become invalid.

Update: Thought I would add a side-note. If you are creating changes that others will review, then it's not uncommon to create a branch with those changes and rebase periodically to keep them up-to-date with the main development branch. Just let other developers know this will happen periodically so they'll know what to expect.

Update 2: Because of the increasing number of viewers I'd like to add some additional information on what to do when your upstream does experience a force push.

Say I've cloned your repo and have added a few commits like so:

            D----E  topic
           /
A----B----C         development

But later the development branch is hit with a rebase, which will cause me to receive an error like so when I run git pull:

Unpacking objects: 100% (3/3), done.
From <repo-location>
 * branch            development     -> FETCH_HEAD
Auto-merging <files>
CONFLICT (content): Merge conflict in <locations>
Automatic merge failed; fix conflicts and then commit the result.

Here I could fix the conflicts and commit, but that would leave me with a really ugly commit history:

       C----D----E----F    topic
      /              /
A----B--------------C'  development

It might look enticing to use git pull --force but be careful because that'll leave you with stranded commits:

            D----E   topic

A----B----C'         development

So probably the best option is to do a git pull --rebase. This will require me to resolve any conflicts like before, but for each step instead of committing I'll use git rebase --continue. In the end the commit history will look much better:

            D'---E'  topic
           /
A----B----C'         development

Update 3: You can also use the --force-with-lease option as a "safer" force push, as mentioned by Cupcake in his answer:

Force pushing with a "lease" allows the force push to fail if there are new commits on the remote that you didn't expect (technically, if you haven't fetched them into your remote-tracking branch yet), which is useful if you don't want to accidentally overwrite someone else's commits that you didn't even know about yet, and you just want to overwrite your own:

git push <remote> <branch> --force-with-lease

You can learn more details about how to use --force-with-lease by reading any of the following:

  • git push documentation
  • Git: How to ignore fast forward and revert origin [branch] to earlier commit?
2 of 6
167

You want to force push

What you basically want to do is to force push your local branch, in order to overwrite the remote one.

If you want a more detailed explanation of each of the following commands, then see my details section below. You basically have 4 different options for force pushing with Git:

git push <remote> <branch> -f
git push origin master -f # Example

git push <remote> -f
git push origin -f # Example

git push -f

git push <remote> <branch> --force-with-lease

If you want a more detailed explanation of each command, then see my long answers section below.

Warning: force pushing will overwrite the remote branch with the state of the branch that you're pushing. Make sure that this is what you really want to do before you use it, otherwise you may overwrite commits that you actually want to keep.

Force pushing details

Specifying the remote and branch

You can completely specify specific branches and a remote. The -f flag is the short version of --force

git push <remote> <branch> --force
git push <remote> <branch> -f

Omitting the branch

When the branch is omitted, Git will figure it out based on your config settings. In Git versions after 2.0, a new repo will have default settings to push the currently checked-out branch:

git push <remote> --force

while prior to 2.0, new repos will have default settings to push multiple local branches. The settings in question are the remote.<remote>.push and push.default settings (see below).

Omitting the remote and the branch

When both the remote and the branch are omitted, the behavior of just git push --force is determined by your push.default Git config settings:

git push --force
  • As of Git 2.0, the default setting, simple, will basically just push your current branch to its upstream remote counter-part. The remote is determined by the branch's branch.<remote>.remote setting, and defaults to the origin repo otherwise.

  • Before Git version 2.0, the default setting, matching, basically just pushes all of your local branches to branches with the same name on the remote (which defaults to origin).

You can read more push.default settings by reading git help config or an online version of the git-config(1) Manual Page.

Force pushing more safely with --force-with-lease

Force pushing with a "lease" allows the force push to fail if there are new commits on the remote that you didn't expect (technically, if you haven't fetched them into your remote-tracking branch yet), which is useful if you don't want to accidentally overwrite someone else's commits that you didn't even know about yet, and you just want to overwrite your own:

git push <remote> <branch> --force-with-lease

You can learn more details about how to use --force-with-lease by reading any of the following:

  • git push documentation
  • Git: How to ignore fast forward and revert origin [branch] to earlier commit?
🌐
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 ...
Discussions

How do I push a new local branch to a remote Git repository and track it too? - Stack Overflow
How do I: Create a local branch from another branch (via git branch or git checkout -b). Push the local branch to the remote repository (i.e. publish), but make it trackable so that git pull and ... More on stackoverflow.com
🌐 stackoverflow.com
Am I using git push --force the right way?
That sounds like the right approach, and the one I use. After the rebase, your local dev1 history is different than the remote's dev1 branch. That is expected after a rebase, because a rebase changes history. Though I would recommend that you use --force-with-lease instead of --force to avoid clobbering any commits that you do not have locally which might have been pushed to the dev1 branch. Just a good habit. More on reddit.com
🌐 r/git
9
7
October 4, 2018
How do I properly force a Git push? - Stack Overflow
I found out that even I'm on my local branch B, I still need to do git push --force origin B:C. In my case, it seems that git push --force origin C will only push from local master to remote C branch, regardless of which branch I'm currently on. More on stackoverflow.com
🌐 stackoverflow.com
git push force on my branch
As mentioned, this is bad practice. A safer option is git push --force-with-lease. Here's the documention with a jump right to the relevant section. More on reddit.com
🌐 r/git
7
6
May 15, 2021
🌐
Git
git-scm.com › docs › git-push
Git - git-push Documentation
The <src> is often the name of the local branch to push, but it can be any arbitrary "SHA-1 expression" (see gitrevisions[7]). The <dst> determines what ref to update on the remote side. It must be the name of a branch, tag, or other ref, not an arbitrary expression. The + is optional and does the same thing as --force...
🌐
freeCodeCamp
freecodecamp.org › news › git-push-to-remote-branch-how-to-push-a-local-branch-to-origin
Git Push to Remote Branch – How to Push a Local Branch to Origin
April 26, 2021 - --force-with-lease alone, without specifying the details, will protect all remote refs that are going to be updated by requiring their current value to be the same as the remote-tracking branch we have for them. Basically, you're telling Git to force update this branch only if it looks the same as when you last saw it. If you're collaborating with others on your branch, it would be good to either avoid using --force or at least use --force-with-lease to prevent losing changes other collaborators have made. You will usually push your local branch to a remote branch of the same name—but not always.
🌐
DataCamp
datacamp.com › tutorial › git-push-force
Git Push Force: How it Works and How to Use it Safely | DataCamp
July 24, 2025 - Now, picture your Git branch like a chapter in a shared book that your team is writing together. A standard push is like adding new paragraphs at the end of the chapter. However, a git push --force is more powerful and rips out the current chapter and replaces it entirely with your version.
🌐
Atlassian
atlassian.com › git › tutorials › syncing › git-push
Git Push | Atlassian Git Tutorial
Git prevents you from overwriting the central repository’s history by refusing push requests when they result in a non-fast-forward merge. So, if the remote history has diverged from your history, you need to pull the remote branch and merge it into your local one, then try pushing again. This is similar to how SVN makes you synchronize with the central repository via svn update before committing a changeset. The --force flag overrides this behavior and makes the remote repository’s branch match your local one, deleting any upstream changes that may have occurred since you last pulled.
Find elsewhere
🌐
Graphite
graphite.com › guides › git-force-push
How to Git force push - Graphite
The git force push command is typically used in scenarios where you need to update the commit history on a remote repository to match your local repository, even if it means discarding changes that are on the remote but not in your local repository.
🌐
GitKraken
gitkraken.com › home › learn › git push
Learn How to Git Push | Git Push Local Branch to Remote
March 14, 2022 - To delete a remote branch using the CLI navigate to the terminal and use: ... Force pushing is a variation of the Git push command, and is an effective way to overwrite commit history stored on a remote repository with your local history.
🌐
GitHub
docs.github.com › en › get-started › using-git › pushing-commits-to-a-remote-repository
Pushing commits to a remote repository - GitHub Docs
As an example, you usually run git push origin main to push your local changes to your online repository. To rename a branch, you'd use the same git push command, but you would add one more argument: the name of the new branch.
🌐
W3Schools
w3schools.com › git › git_branch_push_to_remote.asp
Git Push Branch to Remote
git push --force origin update-readme · Remove a branch from {{title}}: git push origin --delete update-readme · Push all your local branches to {{title}}: git push --all origin · Push all your tags to {{title}}: git push --tags · Rejected ...
🌐
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 - Instead, you can use the “–force-with-lease” option only to push those changes if the state of the remote branch matches what you have locally. The syntax will look something like this: ... The above command is a safe way to invoke the ...
🌐
GitKraken
gitkraken.com › home › learn › problems & solutions › git push force
How to Git Push Force | Solutions to Git Problems
August 5, 2022 - Once you’re satisfied with your local repo, you can push your changes to the remote using the Push button. When force pushing with GitKraken Client, a banner will appear with the following options: Pull (fast forward if possible), Force Push or Cancel. Note: Pull (fast forward if possible) fetches any updates on the remote branch and attempts to fast-forward, or move, the local branch to point to the same commit as the remote.
🌐
Reddit
reddit.com › r/git › am i using git push --force the right way?
r/git on Reddit: Am I using git push --force the right way?
October 4, 2018 -

Hello everyone,

I would like to know if I'm using git push --force the right way. Here is my scenario:

  1. I branched off master (let's call my branch dev1) which I did some work on and then pushed up remotely

  2. A ton of work has been done on `master` I've been working on dev1 locally

  3. I want my local dev1 branch to have all the updated changes that master has so I rebased

  4. At this point, my local dev1 is way out of sync with remote dev1. Git is saying if I want to sync them up then I need to do a git pull (but I definitely don't want to pull the changes down from the remote branch to my newer, local branch).

Assuming no one else works on dev1, am I supposed to git push --force to sync local `dev1` to remote `dev1`? If not, what are my alternatives?

🌐
LabEx
labex.io › tutorials › git-how-to-force-push-changes-to-a-remote-git-repository-415411
How to force push changes to a remote Git repository | LabEx
## Assuming you've already fixed the issue locally git rebase -i HEAD~3 ## Interactively rebase the last 3 commits ## Mark the problematic commit for deletion, save and exit git push --force · If you've been working on a feature branch for ...
🌐
TheServerSide
theserverside.com › blog › Coffee-Talk-Java-News-Stories-and-Opinions › git-push-new-branch-remote-github-gitlab-upstream-example
Git push new local branch to remote
August 31, 2025 - Create a new, local Git branch in your repository. Perform a git push origin -u <branchname> command to push to the remote repo.
🌐
Medium
medium.com › @python-javascript-php-html-css › how-to-force-a-git-push-correctly-6be2c833ec40
How to Force a Git Push Correctly | by Denis Bélanger
August 24, 2024 - This ensures that the local branch mirrors the remote state exactly before attempting any further operations. The use of git push origin temp-branch:main — force in the script forcefully updates the remote main branch with the contents of ...
🌐
freeCodeCamp
freecodecamp.org › news › git-push-local-branch-to-remote-how-to-publish-a-new-branch-in-git
Git Push Local Branch to Remote – How to Publish a New Branch in Git
September 9, 2022 - To confirm the remote has been added, run git remote -v: To finally push the repo, run git push -u origin <branch-name> (“main” is the name of that branch for me). It could be master or Main for you.
Top answer
1 of 12
3320

Just do:

git push origin <your_branch_name> --force

or if you have a specific repo:

git push https://git.... --force

This will delete your previous commit(s) and push your current one.

It may not be proper, but if anyone stumbles upon this page, thought they might want a simple solution...

Short flag

Also note that -f is short for --force, so

git push origin <your_branch_name> -f

will also work.

2 of 12
327

And if push --force doesn't work you can do push --delete. Look at 2nd line on this instance:

git reset --hard HEAD~3  # reset current branch to 3 commits ago
git push origin master --delete  # do a very very bad bad thing
git push origin master  # regular push

But beware...

Never ever go back on a public git history!

In other words:

  • Don't ever force push on a public repository.
  • Don't do this or anything that can break someone's pull.
  • Don't ever reset or rewrite history in a repo someone might have already pulled.

Of course there are exceptionally rare exceptions even to this rule, but in most cases it's not needed to do it and it will generate problems to everyone else.

Do a revert instead.

And always be careful with what you push to a public repo. Reverting:

git revert -n HEAD~3..HEAD  # prepare a new commit reverting last 3 commits
git commit -m "sorry - revert last 3 commits because I was not careful"
git push origin master  # regular push

In effect, both origin HEADs (from the revert and from the evil reset) will contain the same files.


edit to add updated info and more arguments around push --force

Consider pushing force with lease instead of push, but still prefer revert

Another problem push --force may bring is when someone push anything before you do, but after you've already fetched. If you push force your rebased version now you will replace work from others.

git push --force-with-lease introduced in the git 1.8.5 (thanks to @VonC comment on the question) tries to address this specific issue. Basically, it will bring an error and not push if the remote was modified since your latest fetch.

This is good if you're really sure a push --force is needed, but still want to prevent more problems. I'd go as far to say it should be the default push --force behaviour. But it's still far from being an excuse to force a push. People who fetched before your rebase will still have lots of troubles, which could be easily avoided if you had reverted instead.

And since we're talking about git --push instances...

Why would anyone want to force push?

@linquize brought a good push force example on the comments: sensitive data. You've wrongly leaked data that shouldn't be pushed. If you're fast enough, you can "fix"* it by forcing a push on top.

* The data will still be on the remote unless you also do a garbage collect, or clean it somehow. There is also the obvious potential for it to be spread by others who'd fetched it already, but you get the idea.

🌐
Microsoft Learn
learn.microsoft.com › en-us › visualstudio › version-control › git-push-remote
Push to a remote branch in Visual Studio | Microsoft Learn
January 27, 2026 - To push to your remote, select Push button (the up arrow), or select Push from the Git menu. If the local branch is behind the remote branch, git doesn't allow a normal push, and you're prompted for what to do next.