Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I choose to overwrite remote repository with local commits?

Tags:

git

unfuddle

Basically, due to events beyond my control, my remote repo was moved - I did a lot of work on my local copy in the meantime and now I really just want to overwrite everything in the remote repo with my local files.

However, I don't seem to be able to do this. The closest I can get is to pull and merge, but then it wants to walk me through some convoluted process for merging. I don't want to merge. I want to overwrite. I don't need a new branch - basically, I just want a fresh start.

The remote repo is on unfuddle.

like image 668
ericgr Avatar asked Dec 05 '11 14:12

ericgr


1 Answers

You can remove the branch and recreate it, let's say the branch that you want to overwrite is dev:

Remove the branch in your remote host(github)

git push origin :dev   

Then just push your dev again:

git push origin dev 

I use Github for hosting, not familiar with unfuddle, but I think it'll works for the unfuddle, too. :)


Just as @melee mentioned, you can also use

git push origin dev -f 

(not sure whether the -f is valid, but --force is OK)

git push origin dev --force 

to force overwrite the branch. I remember I did it before. Thanks @melee. :)

like image 79
Kjuly Avatar answered Sep 25 '22 14:09

Kjuly