1.

What are the steps to unstage files and discard the changes in working directory?

Answer»

 If the git status command displays 'myfile.txt' as file PENDING to commit then

  1. To unstage a file(which is not yet committed but in staging stage); command 'git reset <file-name>' is USED. After using 'git reset HEAD myfile.txt' command; 'git status' command will not show myfile.txt in the list of files pending to commit, now it will be DISPLAYED under the list of the unstage/untracked files.
  2.   Now to discard the changes('myfile.txt') in working directory; command 'git checkout -- <file-name> is used. After using 'git checkout -- myfile.txt' command; 'git status' command will not show myfile.txt in the list of unstage/untracked files as this file 'myfile.txt' will be replaced with the last committed version from the repository.


Discussion

No Comment Found