在 git 中,可以使用-字符星来处理远程名称。
例如,我们可以添加一个以 开头的远程,只需使用git 命令中的-选项(命令选项和远程名称之间分开)即可更新它。----
但它不起作用:
git pull -- "-myremotename" "master"
Run Code Online (Sandbox Code Playgroud)
而且,我收到此错误消息:
error: unknown switch `y'
usage: git fetch [<options>] [<repository> [<refspec>...]]
Run Code Online (Sandbox Code Playgroud)
我认为该--选项在 中不起作用git pull,因为它是后跟 ,pull的组合,并且在执行这两个命令时不使用。git fetchgit merge--
有办法解决吗?
有办法解决吗?
在远程名称前添加单词前缀safe
$ git remote rename {,safe}-myremotename
Run Code Online (Sandbox Code Playgroud)
然后您可以再次使用它
$ git pull safe-myremotename
Successfully rebased and updated refs/heads/develop
Run Code Online (Sandbox Code Playgroud)
正如您的问题所示,由于远程名称位于文件系统中并且也容易被注入,因此请考虑以下事项:
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
a b c d e f g h i j k l m n o p q r s t u v w x y z
0 1 2 3 4 5 6 7 8 9 . _ -
Run Code Online (Sandbox Code Playgroud)
不要使用破折号-作为第一个字符。(参考)
请勿仅在远程名称中使用任何数字0-9和字母a-f/ (如果名称长度超过三个字符)。否则,远程名称可能会在您的存储库的未来被拒绝。(参考)A-Fgit(1)
以及更多一般性的内容:
0-9。.结束名称,此处为_或-。a-z 或upper A-Z。感谢您的提问。正如您所写,允许在调用时git-pull(1)指定远程名称,远程名称将逐字传递到参数列表中。--git-fetch(1)
它看起来并不像普通的注入就能获得整个面包店的所有权。唯一可以注入的git-fetch(1)是配置的单个remote.<name>参数。
例如,使用名为的单个远程,--all我们可以发送git-pull(1)(并且通过)git-fetch(1)到子递归中。这很有趣,但也有垃圾邮件tty
遥控器名称:--all
进程树git pull -- --all(限制为6行):
121540 Ss+ 00:00:00 -/bin/sh
122011 T 00:00:00 \_ git pull -- --all
122012 T 00:00:00 \_ /usr/lib/git-core/git fetch --update-head-ok --all
122023 T 00:00:00 \_ /usr/lib/git-core/git fetch --append --no-auto-gc --no-write-commit-graph --update-head-ok --all
122034 T 00:00:00 \_ /usr/lib/git-core/git fetch --append --no-auto-gc --no-write-commit-graph --update-head-ok --all
122045 T 00:00:00 \_ /usr/lib/git-core/git fetch --append --no-auto-gc --no-write-commit-graph --update-head-ok --all
Run Code Online (Sandbox Code Playgroud)
git-fetch(1)这里已经有技巧了吗?有点像,但前提是--jobs=1。使用--jobs=2或高于 时2,会更git-fetch(2)顺序地处理选项,而不是一遍又一遍地处理选项。但前提是至少有两个遥控器。
121540 Ss+ 00:00:00 -/bin/sh
127528 T 00:00:00 \_ git fetch --all
127539 T 00:00:00 \_ /usr/lib/git-core/git fetch --append --no-auto-gc --no-write-commit-graph --all
127550 T 00:00:00 \_ /usr/lib/git-core/git fetch --append --no-auto-gc --no-write-commit-graph --all
127561 T 00:00:00 \_ /usr/lib/git-core/git fetch --append --no-auto-gc --no-write-commit-graph --all
127572 T 00:00:00 \_ /usr/lib/git-core/git fetch --append --no-auto-gc --no-write-commit-graph --all
127583 T 00:00:00 \_ /usr/lib/git-core/git fetch --append --no-auto-gc --no-write-commit-graph --all
127594 T 00:00:00 \_ /usr/lib/git-core/git fetch --append --no-auto-gc --no-write-commit-graph --all
127605 T 00:00:00 \_ /usr/lib/git-core/git fetch --append --no-auto-gc --no-write-commit-graph --all
127616 T 00:00:00 \_ /usr/lib/git-core/git fetch --append --no-auto-gc --no-write-commit-graph --all
Run Code Online (Sandbox Code Playgroud)
嗯,看起来像。git-fetch --all没有健全性检查来检测它是否可以重入相同的远程名称,也似乎没有一个带有自己的参数的选项来表示远程(通过名称或 URL),这可以防止这种情况发生。
(git版本2.25.1)