Question

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?

Était-ce utile?

La solution

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
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top