The remote repository contains a bad version. I have the copy of a good version locally. I want to replace everything that's on the remote repository with my current repository (the remote repository has a few more commits (including a merge) that should not have happened).
If I try to push, it tells me I need to pull first, but I don't want to do that, because that would mess my local version. I want the remote repo to contain what I have locally.
How can I do that?
Change Git Remote URL For example, let's say that you want to change the URL of your Git origin remote. In order to achieve that, you would use the “set-url” command on the “origin” remote and you would specify the new URL. Congratulations, you successfully changed the URL of your Git remote!
What you basically want to do is to force push your local branch, in order to overwrite the remote one. If you want a more detailed explanation of each command, then see my long answers section below. Warning: force pushing will overwrite the remote branch with the state of the branch that you're pushing.
Use the --force
, Luke.
http://www.kernel.org/pub/software/scm/git/docs/git-push.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With