Git

Last Updated: 7/27/2023

Unstaging Files

  • We can easily restore files in different environments in working directory or in the staging area.
  • You can use git reset or git restore (preferred) to un-stage files.
git restore --staged file1.txt
git restore --staged file1.txt file2.txt
git restore --staged file1.txt *.txt
git restore --staged .
  • Git restore takes the last copy of the file from the last snapshot and put it in the staging area.
  • In case of new file, it is going to remove the file from the staging area and take it back to its previous state, which is a new untracked file.