ST80
ST80

Reputation: 3903

Git how to overrride local repository with remote repository?

I want to overide my local project with an remote repository. So before I do something unedible, should I "just" do:

cd path/to/project

and then

git pull https://github.com/someuser/someproject.git

??

Upvotes: 0

Views: 40

Answers (3)

Mikhail Vladimirov
Mikhail Vladimirov

Reputation: 13890

Probably git reset --hard origin/HEAD is what you need. It will revert all changes not pushed to remote repository.

Upvotes: 4

René Höhle
René Höhle

Reputation: 27325

There are some things you should check. So if you try to change your repo to a new one. You can go to your .git/config and change the path to the new repository. The repositories have to be identical.

Ich you have changed you can pull new changes from the new one with:

git pull origin branchname

Otherwise if you have local changes then you have to reset your branch first and then pull.

git reset --hard HEAD^ 

which reverts your changes to the last commit.

Upvotes: 0

spinyBabbler
spinyBabbler

Reputation: 407

When you say override, this local project will be identical to remote repository?

If so,

How about go to a directory where you want to put it so cd path/to

Then,

git clone https://github.com/someuser/someproject.git

which will bring someproject into path/to. Fresh and new!

Upvotes: 0

Related Questions