Git 拒绝跟踪或以其他方式识别远程分支

Git refuses to track or otherwise recognize the remote branch

git fetch origin 没有得到新分支,因此 --track 总是失败,无论我尝试什么。

https://gist.github.com/dubslow/dab61346cc06d6b9cf7b

这就是 ^ 我尝试过的一切。您会注意到,我尝试了相关问题 "Cannot update paths and switch to branch at the same time" 中的所有命令,但仍然没有成功。我不知道发生了什么。

编辑:通过这个新的本地分支,我试图推送到我自己的远程,但收到了这条令人困惑的消息:

bill@Gravemind⌚1643 ~/qtox/libs/libtoxcore-latest ∰∂ git remote add mine ssh://git@github.com/dubslow/toxcore.git
bill@Gravemind⌚1644 ~/qtox/libs/libtoxcore-latest ∰∂ git push mine new_api
Counting objects: 566, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (461/461), done.
Writing objects: 100% (566/566), 549.87 KiB | 0 bytes/s, done.
Total 566 (delta 302), reused 260 (delta 102)
To ssh://git@github.com/dubslow/toxcore.git
 ! [remote rejected] new_api -> new_api (shallow update not allowed)
error: failed to push some refs to 'ssh://git@github.com/dubslow/toxcore.git'
bill@Gravemind⌚1644 ~/qtox/libs/libtoxcore-latest ∰∂ git push mine +new_api
Counting objects: 566, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (461/461), done.
Writing objects: 100% (566/566), 549.87 KiB | 0 bytes/s, done.
Total 566 (delta 302), reused 260 (delta 102)
To ssh://git@github.com/dubslow/toxcore.git
 ! [remote rejected] new_api -> new_api (shallow update not allowed)
error: failed to push some refs to 'ssh://git@github.com/dubslow/toxcore.git'

编辑:正如安德鲁 C 指出的那样,那些错误消息意味着回购是一个浅层克隆,我完全忘记了,错误消息相当无用(除了我尝试推送时,那些只是对 git 更有经验的人有点用处。

一个简单的 git checkout new_api 应该可以工作,前提是您还没有同名的本地分支。您(不小心)创建的同名本地 ref 会发生冲突,因此请先使用 git branch -d new_api.

将其删除
git checkout <branch>
   To prepare for working on <branch>, switch to it by updating
   the index and the files in the working tree, and by pointing HEAD at
   the branch. Local modifications to the files in the working tree are
   kept, so that they can be committed to the <branch>.

   If <branch> is not found but there does exist a tracking branch in
   exactly one remote (call it <remote>) with a matching name,
   treat as equivalent to

       $ git checkout -b <branch> --track <remote>/<branch>

这种语法

git checkout <branch>

<branch> 尚不存在时,仅当 <branch> 存在于单个遥控器上时才有效。如果您有多个遥控器,则需要使用

明确说明要跟踪哪个遥控器

git checkout -b <branch> <remote>/<branch>

你的这部分错误信息

(shallow update not allowed)

建议你有一个浅克隆,它会导致各种奇怪的行为。