In addition, the git-checkout man manual says this
-f, --force
When switching branches, proceed even if the index or the working tree differs from HEAD. This is used to throw away local changes.
Changed the file, added a file and tested it
rails@1hao:~/tmp/tmp$ git status
# On branch hello
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: b
#
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: a
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# c
rails@1hao:~/tmp/tmp$ git checkout -f
rails@1hao:~/tmp/tmp$ git status
# On branch hello
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# c
nothing added to commit but untracked files present (use "git add" to track)
The files that were changed and added to the cache are gone
checkout is a local command
Git can be used without an Internet connection, your understanding is correct
git checkout -f I tested it and the result is like this
In addition, the git-checkout man manual says this
Changed the file, added a file and tested it
The files that were changed and added to the cache are gone