git脱离头后拉浅克隆

时间:2018-11-08 09:39:23

标签: git git-detached-head shallow-clone

让我们考虑以下两种情况。

案例1(浅克隆)。

$ git clone --depth 5 ssh://{REMOTE_URL}/project.git
...
$ git checkout fd459887439f2cf93725c2f4a1a39997e865a86d // it is just a latest commit (took it from "git rev-parse HEAD")
...
$ git branch
* (detached from fd45988)
  master

$ git pull
Already up-to-date.

案例2(无--depth的克隆)。

$ git clone ssh://{REMOTE_URL}/project.git
...
$ git checkout fd459887439f2cf93725c2f4a1a39997e865a86d // it is just a latest commit (took it from "git rev-parse HEAD")
...
$ git branch
* (detached from fd45988)
  master

$ git pull
You are not currently on a branch. Please specify which
branch you want to merge with. See git-pull(1) for details.

    git pull <remote> <branch>

因此,区别仅在于在第一种情况下我克隆了有限数量的提交,而在第二种情况下我克隆了所有提交。两种情况下的分支与显示的“ git branch”输出相同。

问题:为什么“拉”在第一种情况下有效而在第二种情况下无效?

0 个答案:

没有答案