Git: How to overwrite local change?
I use git clone from github and I dele开发者_如何学Cted 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?
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
git checkout <name of file>
If you want to check out the whole repository, then from the root directory use
git checkout .
git reset --hard
Git command to pull all changes from branch by overwriting all local changes:-
git reset --hard HEAD
git pull
You can remove local changes by this command
git clean -f
and pull changes by:
git pull
精彩评论