Restore an unstaged file to the version of the current commit (HEAD)

git restore

  • Restore working tree files. Requires Git version 2.23+.
    See also `git checkout` and `git reset`.
    More information: <https://git-scm.com/docs/git-restore>.
  • Trick copyright: tl;dr; <https://github.com/tldr-pages/tldr>

git restore {{path/to/file}}

click the source code to copy install git restore on any operating system with command-not-found.com