git reset of a single file
Snippet
kitt decided around 11:16 on 18 December 2018 to publish this:
git reset
will discard any local changes you have in the current branch you have checked out.
Sometimes, however, you want to reset a single file, not the whole branch. In this case, use checkout
, but use the special "option" --
, which is unix for "treat every argument after this point as a file name, no matter what it looks like."
# general case git checkout HEAD -- [file] # my specific case used ALL THE TIME git checkout HEAD -- package-lock.json
Source: