-- stands for "Anyway, treat the argument after it as a filename (filename)" This is a common Unix convention (not git only), such as:
rm -f # 不造成任何影响
rm -- -f # 删除一个名为 "-f" 的文件
If the file name you want to operate is preceded by -, you can execute git checkout -- -file-,就可以执行 git checkout -- -file 如果你要操作的文件名恰好也属于一个分支名,就可以执行 git checkout -- branchIf the file name you want to operate happens to also belong to a branch name, You can execute git checkout -- branch to ensure that the file (named branch) is being operated on.
is used for escaping. For example, if you have a file named master, if you
It will obviously only pull the code of the master branch, which is not consistent with what you want. When you execute
That’s it to actually pull the master file
--
stands for "Anyway, treat the argument after it as a filename (filename)"This is a common Unix convention (not git only), such as:
If the file name you want to operate is preceded by
-
, you can executegit checkout -- -file
-
,就可以执行git checkout -- -file
如果你要操作的文件名恰好也属于一个分支名,就可以执行
git checkout -- branch
If the file name you want to operate happens to also belong to a branch name, You can executegit checkout -- branch
to ensure that the file (named branch) is being operated on.