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

时间:2015-02-13 22:39:36

标签: git git-branch git-remote git-checkout git-fetch

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'
编辑:正如Andrew C所指出的那样,那些错误消息意味着repo是一个浅层克隆,我完全忘记了,并且错误消息相当无用(除了当我试图推动时,这些只是那种对git更有经验的人有用。

2 个答案:

答案 0 :(得分:2)

此语法

git checkout <branch>

<branch>尚不存在时,只有在单个遥控器上存在<branch>时才有效。如果您有多个遥控器,则需要明确说明要从哪个遥控器跟踪

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

此部分错误消息

(shallow update not allowed)

建议您使用浅层克隆,这可能会导致各种奇怪的行为。

答案 1 :(得分:0)

如果您没有具有该名称的本地分支,则应该使用简单的git checkout new_api。您(意外)创建的同名的本地引用将发生冲突,因此请先使用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>