我有一个奇怪的情况-我的git工作正常,直到一个小时前左右,但现在当我试图运行
git add * --all
字符串
我得到一个错误error:未知开关“C”。
下面是我得到的输出。我只是从回购中拉出来,其中有一些变化,之后我开始得到这个错误。尝试了一下,发现错误是因为*
符号。如果我把它去掉,它就能工作了...
$ git add * --all
error: unknown switch `C'
usage: git add [options] [--] <pathspec>...
-n, --dry-run dry run
-v, --verbose be verbose
-i, --interactive interactive picking
-p, --patch select hunks interactively
-e, --edit edit current diff and apply
-f, --force allow adding otherwise ignored files
-u, --update update tracked files
-N, --intent-to-add record only the fact that the path will be added later
-A, --all add changes from all tracked and untracked files
--ignore-removal ignore paths removed in the working tree (same as --no-all)
--refresh don't add, only refresh the index
--ignore-errors just skip files which cannot be added because of errors
--ignore-missing check if - even missing - files are ignored in dry run
型
4条答案
按热度按时间dbf7pr2w1#
你不应该有选项(如
--all
),如参数后(如文件名)。试着把它们转换一下:字符串
此外,如果文件名以减号开头,它将被错误地解释为选项(文件
-Clown
看起来像命令行上程序的选项-C -l -o -w -n
)。为了缓解这个问题,你可以使用--
停止选项解析:型
zbwhf8kr2#
开关应该在文件列表之前-我猜你有一个名为
C
的文件,*
是由shell扩展到的。但是请注意,对于--all
,您不需要提供文件列表:字符串
dohp0rv53#
您可能正在Powershell控制台中运行。(这是我的案子)
(If如果你想保持输出在同一个控制台窗口中,你可以通过
cmd
在你的控制台中启动一个“普通”命令。(它将有自己的历史,虽然)然后你离开它的exit
。)nhjlsmyf4#
如果您使用的是Windows,可能是因为您使用的是Visual Studio的命令提示符,或其他一些特殊的Windows命令实用程序。使用基本的命令提示符,或者使用Git Bash(我就是这么做的)。我尝试的命令是:
字符串
在git-bash窗口中尝试过之后,它成功了。