What is the difference between git restore --staged some-file and git checkout -- some-file?

Viewed 579

I am exploring the possible options to undo something that has been done with git. I came across this post and I see that there are 3 options git reset, git checkout and git restore.

I think I sort of understand what git reset does (not entirely but I think that's a separate question), however I don't understand what difference is there in running git checkout -- some_file and git restore --staged some_file

Is there a difference in how the two commands change the files in the working directory?

1 Answers

To sumarize Torek's answer:

Torek insists on the fact git restore --source <aCommit> --worktree -- somefile is new (cannot be done with checkout): the abillity to restore a file in the workig tree without touching the index.

Related