0

I have a remote repository that I have to clone at depth 1 using git clone --depth 1 [url] and then use git fetch --unshallow and git fetch --all to get the full repository.

The problem is that I can only see branches that I have created locally. I cannot see any remote branches unless I created them locally and pushed them to the remote server. This means that if anything happens to my local repo, I will have to start work on any remote branches all over again.

Edit: This question is answered elsewhere, but I am leaving it up because it asks the question in a different way, making the solution more searchable.

How do I resolve this issue?

Hebron Watson
  • 383
  • 2
  • 9
  • 1
    This question is answered [here, in another StackOverflow Answer](https://stackoverflow.com/questions/11623862/fetch-in-git-doesnt-get-all-branches/25941875#25941875). – Hebron Watson Aug 25 '21 at 19:43
  • 2
    Note that even with a normal, non-shallow clone, you get all the *commits* from the other Git repository, but *none of their branches*. At the last minute—and only if you don't use the `-n` or `--no-checkout` option—your own Git software creates a *new* branch in your clone, from the *remote-tracking* names that your Git used to remember their *branch* names. Using `--depth` implies `--single-branch`, which tells your Git: *don't make remote-tracking names for all their branches, just make one for one of their branches.* – torek Aug 25 '21 at 21:25
  • 2
    You can deepen a shallow clone without adding more remote-tracking names, or you can de-single-branch a single-branch-clone without deepening (if it's shallow), or you can unshallow a shallow clone with or without de-single-branching it; these are all independent. – torek Aug 25 '21 at 21:27

0 Answers0