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.

Answer from Katie on Stack Overflow
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.

🌐
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.
Discussions

Is force pushing really bad practice?
What you do is pretty common. Force pushing rewrites history; this is an issue if you care about that history. On a short-lived branch that exists only for a PR, no one cares about history. On main or any long-lived branch shared by multiple people, history is very important, and force pushing should never be used. More on reddit.com
🌐 r/git
27
11
June 8, 2024
Is using force push standard workflow for GitHub?
This isn't a github problem but rather is a side effect of what "rebasing" is doing. Rebasing effectively replays your commits on top of the new "base" of your branch. However while those replayed commits contain the same changes as they did before the rebase, they aren't actually the same commits. So you can' t do a standard push because you aren' t pushing new commits on top of your branch - you're effectively replacing your old branch with the new commits. And to do that you have to force push. If you don't want to force push you can merge the master branch into your feature branch instead of rebasing. You'll need to reset your branch to its previous state, merge the master branch into your feature branch, and push as normal. That will do the same effective thing as the rebase (integrate updates in master into your branch) but will do that in a merge commit instead of re-doing your commits. $ git checkout feature-branch $ git reset --hard origin/feature-branch $ git pull origin master $ git push IMO the rebase and force push workflow is a perfectly fine if You're working on a feature branch You're the only person working on the branch You haven't put up a PR for review If all of those conditions are met, rebasing and force pushing is a very nice way of keeping a clear branch history. However if anyone else is using your branch or looking at your code, force pushing is quite jarring and should be avoided at all costs. You can check out the Git documentation on rebase and the Atlassian tutorial on merging vs rebasing for more context. More on reddit.com
🌐 r/git
17
8
April 16, 2021
Git push force 💥
If your repo allows users to mess with master then you deserve it. More on reddit.com
🌐 r/ProgrammerHumor
81
4922
December 13, 2022
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
🌐
Git
git-scm.com › docs › git-push
Git - git-push Documentation
I.e. create a base tag for versions of the upstream code that you’ve seen and are willing to overwrite, then rewrite history, and finally force push changes to master if the remote version is still at base, regardless of what your local remotes/origin/master has been updated to in the background.
🌐
Evil Martians
evilmartians.com › blog › git push --force and how to deal with it—martian chronicles, evil martians’ team blog
git push --force and how to deal with it—Martian Chronicles, Evil Martians’ team blog
July 30, 2024 - However, as an excellent guide from a separate field famously reminds us, “DON’T PANIC”! After all, the upside is that you’re using Git, and that means everything can be fixed. Let’s start with the best case scenario: someone else working on the same code pulled a recent version of the main branch just before you broke it. In this case, all you have to do is to go into your team chat and ask this person to force push their recent changes.
🌐
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 ...
🌐
Medium
noaabarki.medium.com › dont-underestimate-the-push-force-5cba944a246d
Don’t Underestimate the push — force | by Noaa Barki | Medium
January 24, 2020 - The force flag allows us to order Git “do it anyway”. Whenever we change our history or whenever we want to push changes that are in consists with the remote branch we should use push — force.
Find elsewhere
🌐
Scaler
scaler.com › home › topics › git › git push force
Git Push Force- Scaler Topics
May 4, 2023 - The command used to push is: If you want to specify the remote name and the branch name, then you can do it with: This --force option will override the constraint of fast forwarding in git and will align the changes of the local branch with the changes of the remote branch on the remote server.
🌐
DEV Community
dev.to › ruqaiya_beguwala › day-1230-git-push-force-with-lease-safer-alternative-to-force-5fc
Day 12/30 - git push --force-with-lease – Safer alternative to --force - DEV Community
June 2, 2025 - Unlike --force, which blindly overwrites the remote branch, --force-with-lease checks if the remote branch has changed since you last fetched it. git push --force → Overwrites remote branch no matter what.
🌐
Git Tower
git-tower.com › blog › force push in git - everything you need to know
Force Push in Git - Everything You Need to Know | Tower Blog
August 18, 2021 - You can use the --force flag (or -f for short). This can look like an easy workaround when the git push command does not work, but it is rarely recommended — it’s not the default behavior for a reason.
🌐
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.
🌐
Educative
educative.io › answers › what-is-the-git-push---force--u-origin-command
What is the git push --force -u origin command?
The git push --force -u origin command overrides this restriction in Git, meaning it allows you to forcefully overwrite the commit history of your local branch to the remote repository branch.
🌐
Graph AI
graphapp.ai › engineering-glossary › git › force-push
Force Push: Definition, Examples, and Applications | Graph AI
In the realm of software development, the term 'Force Push' is a command used in Git, a distributed version control system. This command is used to overwrite the remote repository with local changes. It is a powerful tool that can be both beneficial and destructive if not used correctly.
🌐
Reddit
reddit.com › r/git › is force pushing really bad practice?
r/git on Reddit: Is force pushing really bad practice?
June 8, 2024 -

When I work on a large project, I'll usually create a new branch on my fork for each thing that I implement and maybe reuse branches between PRs. On my branches, I force push a lot. Pretty much after every rebase and in a lot of situations, I don't really have any other choice or at least I don't know how to do what I want to do without force pushing. But since the branches are only used by me, I don't think it matters, right?

I keep hearing about how you are not supposed to force push.

🌐
Adam Johnson
adamj.eu › tech › 2023 › 10 › 31 › git-force-push-safely
Git: Force push safely with --force-with-lease and --force-if-includes - Adam Johnson
October 31, 2023 - The output hint tells you to merge the remote changes with git pull. Sometimes, this is what you want to do, such as when pushing to a shared release branch. But sometimes, it’s not, such as when you have amended a commit, rebased your branch, or removed commits. In those cases, use the Jedi-esque force push, enabled with -f (--force):
🌐
Thoughtbot
thoughtbot.com › blog › git-push-force-with-lease
Force push with care
July 20, 2023 - My coworker Calle (not in the picture) suggested in our guides that we prefer the flag --force-with-lease over --force to the git push command. This option allows one to force push without the risk of unintentionally overwriting someone else’s work. It will update remote references only if it has the same value as the remote-tracking branch we have locally.
🌐
GeeksforGeeks
geeksforgeeks.org › git › how-to-force-git-push
How to Force Git Push? - GeeksforGeeks
July 23, 2025 - Step 4. Commit Changes: Commit the changes using git commit -m "Your commit message". ... Step 5. Force Push: Use the --force option to force push: