Sunday 7 January 2018

Discard unstaged changes in Git

There could be times that you just temporarily tried something, or showing other people something and you have some garbage code.

When using Git, it is common to make changes that you want to remove entirely before the staging phase. For example, after working on a few files, you realize that you want to revert the changes made to one specific file. To discard the changes before staging and committing, use the $git checkout command.

To unstage one file :
$ git checkout <path-to-file>
Remember to replace <path-to-file> with the actual file name.

To unstage all files:
$ git checkout -- .
ref:
https://forum.freecodecamp.org/t/discard-unstaged-changes-in-git/13214

No comments:

Post a Comment