1

I was attempting to clone a repo with git clone git@github.com:someorg/my-repo.git, but the process takes forever to complete after indicating Cloning into 'my-repo' .... I tried :

  1. Generating a key with ssh-keygen -t rsa
  2. Adding the public key located in ~/.ssh/id_rsa.pub to my GitHub account
  3. Setting up an ssh-agent with eval "$(ssh-agent -s)" and adding my key with ssh-add ~/.ssh/id_rsa
  4. Cloning the repo
I.conic
  • 51
  • 5
  • 1
    Unless someone is deliberately slowing ssh traffic and speeding up other traffic, it won't matter what protocol you use to clone: you just have a big repository and/or a tiny straw you're using to suck in the copy. – torek Oct 20 '21 at 21:57

1 Answers1

0

It sounds like you would benefit from doing a shallow clone:

for example:

git clone --depth 10 https://github.com/torvalds/linux.git

from the git man page:

--depth <depth>
  Create a shallow clone with a history truncated to the specified number of commits...
...
...

This won't give you the full git history of the repo but is likely to satisfy your needs. For a start it will give you the latest version of the repo.

Since adding the --depth flag to your clone command reduces the amount of data being downloaded, you should see a reduction in the time it takes to run a clone.

The decrease in time to clone will vary with the size and history of this particular repo. You can later download the rest of the history using:

git fetch --unshallow

See How to convert a Git shallow clone to a full clone? for more details on this.

tjheslin1
  • 1,378
  • 6
  • 19
  • 36
  • 1
    Thanks for your answer, however after investigation the problem was not caused by the size of the repo to clone but only by a temporary ssh connection issue. Restarting my machine has restored the connection. – I.conic Oct 29 '21 at 08:31