0

Are there any differences between git checkout [file] and git reset --mixed [file] commands? I was just curious and was wondering if it has any differences and different side-effect because both commands reset file to initial state?

amerr-k
  • 39
  • 7
  • 1
    The duplicate that was used here is specifically about `git reset` and `git checkout` as used *without* a file name (technically *pathspec*) argument. The square brackets suggest that you're thinking of both usages but they are different. This is why `git checkout` got split into two commands, `git switch` and `git restore`, in Git 2.23 (and I think `git reset` should be "split" as well, although one of the splits *is* `git restore`!). – torek Oct 07 '20 at 22:02
  • 1
    Note that you cannot combine explicit `--hard`, `--soft`, and `--mixed` options with pathspec arguments. The pathspec variant of `git reset` is always equivalent to some `git restore --staged` command. – torek Oct 07 '20 at 22:04

0 Answers0