git checkout --< filename>中的--是做什么用的?
怪我咯
怪我咯 2017-05-02 09:39:05
0
2
574

网易云课堂上的一个问题,事实上 使用 git checkout <filename> 也不会有问题。那 -- 到底是用来做什么?搜了好久不知道哪个是正确答案,求解知道的大神~

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(2)
曾经蜡笔没有小新

is used for escaping. For example, if you have a file named master, if you

git checkout master

It will obviously only pull the code of the master branch, which is not consistent with what you want. When you execute

git checkout -- master

That’s it to actually pull the master file

phpcn_u1582

-- 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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!