Friday, 24 February 2017

Revert changes in git


(1) How to revert files that are not staged in git?

For a specific file use:
git checkout path/to/file/to/revert

For all unstaged files use:

git checkout -- .
OR:
git checkout  .


(2) How to unstage a staged file?
git reset path/to/file/to/revert

(3) Is there a way to delete staged file completely?
 No, git reset will only unstage the staged files, it won't delete the changes,
if you want to delete it completely, you have to do git checkout in step one.

No comments:

Post a Comment