Search code examples
gitrestore

Git: How to overwrite local change?


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?


Solution

  • 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