Want to nuke your local changes and check HEAD back out?
There are plenty of reasons to want to overwrite your local changes to a git repository and check out a clean copy of HEAD. To do that, just issue this command.
git add .; git reset --hard HEAD
The git add .
command makes git aware of any new files that have been created, and the subsequent command tells git to discard all of it.
Written by Blaine Pace
Related protips
1 Response
clever...never used it with git add . I typically reset and then remove new files
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Git
Authors
khasinski
591.1K
dmichaelavila
500.4K
Related Tags
#git
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#