$ git clone -b master https://github.com/jerryc127/hexo -theme-butterfly .git themes/butterfly
error: unknown switch `t'
usage: git clone [<options>] [--] <repo> [<dir>]
-v, --verbose be more verbose
-q, --quiet be more quiet
--progress force progress reporting
--reject-shallow don't clone shallow repository
-n, --no-checkout don't create a checkout
--bare create a bare repository
--mirror create a mirror repository (implies bare)
-l, --local to clone from a local repository
--no-hardlinks don't use local hardlinks, always copy
-s, --shared setup as shared repository
--recurse-submodules[=<pathspec>]
initialize submodules in the clone
--recursive[=<pathspec>]
我想克隆一个 hexo 主题到我的博客文件
此代码应该可以实现您的预期:
git clone -b master https://github.com/jerryc127/hexo themes/butterfly
您收到未知开关“t”的原因是因为 git 命令行界面使用破折号来确定传入的参数。
“双破折号是 shell 命令中使用的一种语法,用于表示命令选项的结束和位置参数的开始。换句话说,它将命令选项与命令操作的参数分开。”
所以 git 正在到达您编写 -themes 的位置,但它首先看到 -t 并抛出您所看到的错误,因为 -t 之后没有空格。
本质上,git 不会将你的 -themes 视为实际主题,而是相当于“我还有另一件事要传递到脚本中”