双重破折号[ - ]选项在git reset上做什么? [英] What does the double-dash [--] option do on git reset?

查看:140
本文介绍了双重破折号[ - ]选项在git reset上做什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看过如下命令:

  git reset e542  -  readme.txt 

我知道这个命令在索引中放入了来自commit e542的文件readme.txt的内容。但是, - 选项在那里做了什么?



git reset手册页列出了前两项的可选项表单,但我找不到它的意思。

  git reset [-q] [< commit>] [ - ]<路径> ... 
git reset(--patch | -p)[< commit>] [ - ] [<路径> ...]
pre>

解决方案

- 从文件名中分离分支名称,有任何含糊之处(如果你有一个分支和一个同名的文件)。如果没有歧义,你不需要 -



同样如Jonas Wielicki所提到的,这允许以 - 开头的文件名;这些将被解释为命令行选项。


I've seen commands like:

git reset e542 -- readme.txt

I understand this command puts in the index the contents of the file readme.txt from commit e542. But what's the -- option doing there?

The git reset man page lists it as optional for the first two forms but I couldn't find what it means.

git reset [-q] [<commit>] [--] <paths>…
git reset (--patch | -p) [<commit>] [--] [<paths>…]

解决方案

-- separates branch names from file names, in case there is any ambiguity (if you have a branch and a file with the same name). If there are no ambiguities, you don't need the --.

Also as mentioned by Jonas Wielicki, this allows for file names that start with a -; these would otherwise be interpreted as command-line options.

这篇关于双重破折号[ - ]选项在git reset上做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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