-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.
改了文件,加了個文件測試了下
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)
checkout是本地指令
git 不需要連網就可以使用,你的理解是對的
git checkout -f 我測試了下,結果是這樣的
另外 git-checkout man手冊裡是這樣說的
改了文件,加了個文件測試了下
那些更改的和加入到快取區的檔案都沒有了