Git pull shallow clone after detached HEAD

421 views Asked by At

Let us consider two following cases.

Case #1 (shallow clone).

$ 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.

Case #2 (clone without --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>

So, the difference is only that in the first case I clone limited number of commits and in the second case I clone all commits. The branch is the same in both cases as shows "git branch" output.

Question: why "pull" does work in the first case and does not work in the second case?

0

There are 0 answers