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
3325

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.

🌐
GeeksforGeeks
geeksforgeeks.org › git › how-to-force-git-push
How to Force Git Push? - GeeksforGeeks
July 23, 2025 - Git is a powerful version control system that helps developers manage and track changes in their codebase. Sometimes, you might need to force push changes to a repository to overwrite previous commits. This article will guide you through creating a GitHub account, setting up a repository, deploying a website, and understanding how to force push in Git.
Discussions

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
Push Force
There is some way to execute this command from the app git push origin -f I can't find any option on menu to force a push More on github.com
🌐 github.com
2
1
April 25, 2024
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
13
June 8, 2024
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
🌐
Git Tower
git-tower.com › learn › git faq › how to force push in git
How to force push in Git | Learn Version Control with Git
5 days ago - Only when you are up-to-date will you be able to push your own new commits to the remote. The --force option for git push allows you to override this rule: the commit history on the remote will be forcefully overwritten with your own local history.
🌐
Graphite
graphite.com › guides › git-force-push
How to Git force push - Graphite
git push -f origin feature-branch · You should then see something like: Terminal · Counting objects: 3, done. Delta compression using up to 4 threads. Compressing objects: 100% (3/3), done.
🌐
Reddit
reddit.com › r/git › is using force push standard workflow for github?
r/git on Reddit: Is using force push standard workflow for GitHub?
April 16, 2021 -

Hello,

I have a feature branch that I had to rebase on the master branch. However, After rebasing the push to the remote feature branch failed with the following error: "Updates were rejected because the tip of your current branch is behind its remote counterpart"

sof: https://stackoverflow.com/questions/39399804/updates-were-rejected-because-the-tip-of-your-current-branch-is-behind-its-remot

Querying the internet tells me the solution is to git push -f to the remote feature branch. Isn't this anti-pattern in git to do a force push just because GitHub cannot automatically fast-forward the rebased commit?

Thoughts? thanks

Top answer
1 of 4
11
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.
2 of 4
1
This is not specific for GitHub. If you would rebase some branch that you share with others (ie any remote branch) you may undo work done by others (thats why you get the warning), sometimes this is necessary. We all use different workflow but I would not use ´push -f´ in my daily workflow, I would use it if I need to clean up something that requires a rebase of a remote branch (and then inform my co-workers). If you are the only developer you may do what you find best for you.
🌐
DataCamp
datacamp.com › tutorial › git-push-force
Git Push Force: How it Works and How to Use it Safely | DataCamp
July 24, 2025 - This restricts direct edits and prevents accidental force pushes to important branches. If you want to learn more about managing private repos, check out our Introduction to GitHub Concepts course to understand how to review pull requests when collaborating on GitHub. git push --force offers a useful method for rewriting your repo’s history, whether you want to clean commits or remove sensitive data.
Find elsewhere
🌐
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 - If your colleague makes changes, ... you run push --force-with-lease on the CLI, you will still overwrite these commits. For this reason, we check if there are unmerged commits on the remote branch and present a warning if we find any. If you’re hosting your remote repository on GitHub, you can use ...
🌐
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 - $ git push --force origin origin/main-before-force-push:main · If you still need your work to be in the main, just rebase on top of it: ... GitHub and GitLab have a feature called “protected branches”. So, we can mark main, develop, stable, or any other crucial branches, as “protected” and no one will be allowed to force push into them.
🌐
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.
🌐
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
In those cases, use the Jedi-esque force push, enabled with -f (--force): $ git push -f ... To github.com:adamchainz/example.git + 1fd4fb8...e025fa5 camembert -> camembert (forced update)
🌐
GitHub
github.com › marketplace › actions › git-commit-and-push-w-force-push
Git Commit and Push w/ Force Push - GitHub Marketplace
name: publish on: push: branches: - master jobs: build: runs-on: ubuntu-latest steps: - name: checkout uses: actions/checkout@master with: ref: master - name: build uses: github-actions-x/hugo@master - name: push uses: dciborow/commit@0.0.2 with: github-token: ${{ secrets.GITHUB_TOKEN }} push-branch: 'master' commit-message: 'publish' force-add: 'true' force-push: 'true' files: a.txt b.txt c.txt dirA/ dirB/ dirC/a.txt name: commiter name email: my.github@email.com
🌐
GitHub
github.com › git-guides › git-push
Git Guides - git push · GitHub
git push -f: Force a push that would otherwise be blocked, usually because it will delete or overwrite existing commits (Use with caution!)
🌐
GitHub
gist.github.com › wojtha › 1281288
Git - force push to remote · GitHub
Git - force push to remote. GitHub Gist: instantly share code, notes, and snippets.
🌐
Scaler
scaler.com › home › topics › git › git push force
Git Push Force- Scaler Topics
May 4, 2023 - Git normally only allows you to push changes if you have previously updated your local branch with the latest commits from your remote. So, you can transfer your own latest code commits to the remote server by using the push command only if they are up to date. If you want to avoid pushing --force altogether, GitHub and GitLab provide us with a very cool feature known as Protected Branches.
🌐
Centron
centron.de › startseite › git push tutorial: commands, examples, and safe force push options
Git Push Tutorial: Commands, Examples, Safe Force Push Options
September 3, 2025 - Grasping this push/pull interaction is essential for handling contributions in distributed workflows. This guide explores how git push operates in scenarios such as GitHub, bare repositories, and force-push workflows, along with usage examples and details about common flags like -u, --tags, and --force.
🌐
YouTube
youtube.com › watch
How to force push to GitHub? - YouTube
🌟 Exclusive Hosting Deal from Hostinger 🌟Ready to launch your own website? Use my affiliate link to get an exclusive discount on Hostinger's reliable and h...
Published   April 19, 2024
🌐
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.
🌐
Datree
datree.io › resources › git-push-force
Git push force [a Git commands tutorial] | Datree.io
January 23, 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.
🌐
GitKraken
gitkraken.com › home › learn › problems & solutions › git push force
How to Git Push Force | Solutions to Git Problems
August 5, 2022 - Learn how to Git push force using GitKraken Client, how to force push in the CLI, and see why force pushing in Git can be considered dangerous and how to mitigate risks.