Git restore vs git rm

What is the difference between git restore --staged and git rm --cached, since both will move the file from staging to working area.

Hello @chive.insole_0a,

  • git rm --cached file : removes the copy of the file from the index / staging-area, without touching the working tree copy. The proposed next commit now lacks the file. If the current commit has the file, and you do in fact make a next commit at this point, the difference between the previous commit and the new commit is that the file is gone.

  • git restore --staged file : Git copies the file from the HEAD commit into the index, without touching the working tree copy. The index copy and the HEAD copy now match, whether or not they matched before. A new commit made now will have the same copy of the file as the current commit.