Git Unstaging - RM or Restore? Why we have different options

Published: 05 October 2024
on channel: A shot of code
95
10

Git gives us two different commands to unstage file changes depending on the state of the repo.

1) rm --cached which simply removes the file from the staging/index area
2) restore --staged which resets the file to the version in the repo

Which one is displayed depends on whether we have any commits in the repo, so with no commits we'll be told to use rm --cached as there is no HEAD to restore too, and if we have commits in the DB the restore --staged is specified as the command to use as otherwise we'll remove the file from the staging/index area which will end up with git status showing us 'deleted' and 'modified'


Watch video Git Unstaging - RM or Restore? Why we have different options online without registration, duration hours minute second in high quality. This video was added by user A shot of code 05 October 2024, don't forget to share it with your friends and acquaintances, it has been viewed on our site 95 once and liked it 10 people.