A problem on NetEase Cloud Classroom. In fact, there will be no problem using git checkout <filename>. So -- what exactly is it used for? I’ve been searching for a long time but I don’t know which is the correct answer. Please ask someone who knows the answer~
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.