user1738984
user1738984

Reputation: 604

Git confusion - how to revert local changes to latest remote push?

I have a local git repository, but things get wrong and complicated and I simply want to overwrite all the files in my local directory with the latest version of what is on the remote repository. This would be like a clone, but for an already setup local git repository.

For example: if use git pull, then I don't get locally deleted folders back from the remote.

Is it checkout that I must use? But how to tell it to retrieve the files from a remote (and not from the stage) and overwrite all?

Upvotes: 42

Views: 34253

Answers (1)

Brian Phillips
Brian Phillips

Reputation: 13053

You probably want to use git reset. Assuming you have done a git fetch recently, the following will discard everything in your local and reset it to the point you specify as the final argument (in this case the current HEAD of the origin/master remote tracking branch):

$ git reset --hard origin/master

Upvotes: 69

Related Questions