Don't use `git checkout` for anything:
- use `git switch` to switch between branches
- use `git restore` to restore files from a given tree
`checkout` has always been regrettably overloaded with those two capabilities, and nowadays you can avoid it by using commands designed for the purpose