106

There is a big repo with thousands of commits. When I clone it, I just want to see the latest code, and don't wait for too long, so I run:

git clone git://..../... --depth 1

But later, I want to see all the history commits, but I don't know how to fetch all the histories.

2
  • I'm pretty sure there's no way to go from this repo to the full version - you will most likely need to clone the entire repo, including the latest revision, into a fresh copy in order to have the full history. I'm not 100% sure that this is the case, however, so I will leave it to somebody with more knowledge in this area to provide a more definitive answer for you.
    – JamesG
    Commented Mar 26, 2015 at 2:33
  • 5
    possible duplicate of Convert shallow clone to full clone
    – Makoto
    Commented Mar 26, 2015 at 2:34

3 Answers 3

161

Use git pull --unshallow and it will download the entire commit history.

4
  • 9
    or use 'git fetch --unshallow'
    – Bill Cong
    Commented Apr 29, 2022 at 15:48
  • 3
    I saw this when I attempted that command: $ git pull --unshallow fatal: --unshallow on a complete repository does not make sense Commented Nov 4, 2022 at 14:55
  • 1
    @RichvonLehe probably means you already got the entire history locally, right? Commented Jul 14 at 9:02
  • that will download all the history. Is there a way to fetch other branches with depth=1? Commented Aug 1 at 10:23
23

Alternatively, you can also run git fetch --depth=1000000.

2
  • 17
    In a few years, this won't work if pulling the Linux kernel. :) Commented Jan 13, 2020 at 1:30
  • 3
    Maybe. but if you, like me, have trouble pulling the entire source because you use an old laptop which runs out of memory, then this is a solution that would work. With patience.
    – Filkolev
    Commented Sep 8, 2020 at 17:13
0

You can also use this and it will only check out the commit metadata, not the trees/blobs.

git fetch --unshallow --filter=tree:0

Then when you check out a commit it will fetch the blobs from the server on demand.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.