How do I properly force a Git push?

The Solution to How do I properly force a Git push? is


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.

~ Answered on 2012-09-26 21:31:33


Most Viewed Questions: