If you need to reset a file on your local branch with main, for example, you can use git show.
git show
$ git show main:package.json > package.json
source