Git: How to overwrite local change?

mlzboy picture mlzboy · Nov 1, 2010 · Viewed 22.1k times · Source

I use git clone from github and I deleted some files & modified some files. Now I want to keep my local code & restore to the original form. Is there a command to achieve this?

Answer

seriyPS picture seriyPS · Nov 1, 2010

If you want to save you changes first, you can commit them before and then checkout you code to previous commit(s): git checkout HEAD^ (one commit back) git checkout GEAD~2 (2 commits back)

Or, if you don't need your changes anymore, run git reset --hard HEAD