这里的关键是添加了第二个远程库。如果你只克隆仓库并立即尝试切换到 master
分支,它将可执行:
mureinik@computer ~/src/git
$ git clone https://github.com/facebook/zstd.git
Cloning into 'zstd'...
remote: Enumerating objects: 9, done.
remote: Counting objects: 100% (9/9), done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 43954 (delta 1), reused 0 (delta 0), pack-reused 43945
Receiving objects: 100% (43954/43954), 23.29 MiB | 682.00 KiB/s, done.
Resolving deltas: 100% (32256/32256), done.
mureinik@computer ~/src/git
$ cd zstd
mureinik@computer ~/src/git/zstd (dev)
$ git checkout master
Switched to a new branch 'master'
Branch 'master' set up to track remote branch 'master' from 'origin'.
一旦您添加了jay
,远程分支名称master
就变得不确定了(它可能指的是origin/master
或jay/master
),因此,当您尝试检出时会失败。
我不确定这是什么时候发生的,但是新版本的git(我正在使用2.28)将在这种情况下给出更清晰的错误消息:
mureinik@computer ~/src/git/zstd (master)
$ git checkout verbose
hint: If you meant to check out a remote tracking branch on, e.g. 'origin',
hint: you can do so by fully qualifying the name with the --track option:
hint:
hint: git checkout --track origin/<name>
hint:
hint: If you'd like to always have checkouts of an ambiguous <name> prefer
hint: one remote, e.g. the 'origin' remote, consider setting
hint: checkout.defaultRemote=origin in your config.
fatal: 'verbose' matched multiple (2) remote tracking branches