How to git force good

A very common statement that’s made:

Git force push is bad

This statement lacks a lot of context and paints a wrong statement.

How to git force push

To do a git force push use the flag — force or -f with the git push command.

git push —- force

(This assumes the “upstream” is already set for the git branch)

This essentially rewrites remote history.

Hold on! Do go through the next section to understand how to effectively use this tool.

How to git force push good

More often that not the discussion has happened how git force push is bad and looked upon. Although like any other tool, it’s about knowing what to use when to use.

My takes is as below:

Force pushing is fine as long as you know what you are doing i.e you are very well aware of the consequences - which here in case is rewriting remote history. If your context declares that is an OK decision to make then nothing to worry about.

Things to know

All in all force push is a nifty feature, it’s like saying a knife is dangerous. It’s not the knife that is dangerous it’s the intent of the person holding it is.


Rewriting remote history: What it means is that the chain of commits that are there in remote will be overwritten by the chain of commits that you have in your local machine. This is a destructive action, meaning it will make changes that are not recoverable (easily).