Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Overriding remote git repository with my repository

Tags:

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?

like image 579
rid Avatar asked Jun 10 '11 17:06

rid


People also ask

How do I override git remote origin?

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!

How do you overwrite a 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.


1 Answers

Use the --force, Luke.

http://www.kernel.org/pub/software/scm/git/docs/git-push.html

like image 145
Amber Avatar answered Oct 12 '22 07:10

Amber