git push –force-with-lease vs. –force

force overwrites a remote branch with your local branch. –force-with-lease is a safer option that will not overwrite any work on the remote branch if more commits were added to the remote branch (by another team-member or coworker or what have you). It ensures you do not overwrite someone elses work by force pushing. I … Read more

Undoing a ‘git push’

You need to make sure that no other users of this repository are fetching the incorrect changes or trying to build on top of the commits that you want removed because you are about to rewind history. Then you need to ‘force’ push the old reference. git push -f origin last_known_good_commit:branch_name or in your case … Read more

Force “git push” to overwrite remote files

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 … Read more