为什么我们在“git checkout - ”中使用双破折号? [英] Why do we use double dash in "git checkout -- ."?

查看:119
本文介绍了为什么我们在“git checkout - ”中使用双破折号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为该行

  git checkout。 

可以恢复本地工作副本的当前目录和子目录中的所有更改。但我也看到这种流行的形式:

  git checkout  - 。 

所以如果 - (双破折号或也称为裸双破折号)是指示命令选项结束,那么为什么在上述情况下需要? 永远不会成为一个选项,因此不应有任何混淆。

解决方案 bob 的分支,那么这个分支就是为了解决歧义性问题。

(它将检出该分支)和一个名为 bob (这将恢复该文件夹)的文件夹。


I thought the line

git checkout .

can revert all changes in the current directory and subdirectory for the local working copy. But I also see this popular form:

git checkout -- .

so if -- (the double dash or also called "bare double dash") is to signal the end of command options, then why is it needed in the above case? The . can never be an option so there shouldn't be any confusion.

解决方案

It's meant to be to resolve ambiguity.

For example, if you had a branch named bob (which would checkout that branch) and a folder named bob (which would revert that folder).

这篇关于为什么我们在“git checkout - ”中使用双破折号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆