5

I want to clone different big GIT repos (like Linux kernel or Android sources) but as they are huge (I know I can limit the size with --depth, but it's not the idea here) I will totally use the home bandwith (450kbps) for days.

I tried the tool trickle and even if it works well on a wget example, it does not work for git clone.

How do you limit the bandiwth of a git clone command ?

Thanks !

gbetous
  • 115
  • 1
  • 9
  • There are a few hints here: http://stackoverflow.com/questions/24480149/using-trickle-with-git – Lajos Veres Jan 02 '15 at 18:10
  • I've seen this, but it does not work. There is not "trick". The -s option simply disable a warning message. – gbetous Jan 03 '15 at 08:44
  • The `-s` option works for me. I did `trickle -s -u 200 -d 200 git clone ssh://@/.git` and Git reports the download going at about 200 KB/s. – ntc2 Sep 25 '15 at 02:03
  • @ntc2 Could you please post your comment as an answer? `echo "alias git='trickle -s -d 4096 -u 1536 /usr/bin/git'" >> ~/.bashrc` – Johannes Sep 26 '21 at 09:13

2 Answers2

6

You can use trickle directly like this

trickle -s -u 200 -d 200 git clone ssh://<user>@<host>/<path to repo>.git

In that example the up and down bandwidth is limited to 200kB/s, but you can adjust to your needs.

ntc2
  • 11,203
  • 7
  • 53
  • 70
3

I would think you want trickle to act on the underlying ssh command used by git (assuming ssh is the underlying protocol for the URL), so something along the lines of this might work (untested - substitute the applicable values for your environment):

$ (echo '#!/bin/sh'; echo 'trickle -s -d 100 -u 100 ssh "$@"') > $HOME/bin/trickle-ssh.sh
$ chmod a+rx $HOME/bin/trickle-ssh.sh
$ export GIT_SSH=$HOME/bin/trickle-ssh.sh

$ git clone ...
ntc2
  • 11,203
  • 7
  • 53
  • 70
Bert F
  • 85,407
  • 12
  • 106
  • 123
  • Thanks but it still not work. If I refer to `man git` GIT_SSH is not used by "git clone". It is only used by "fetch" and "push". By the way, as I am using git:// protocol, I'm not sure it would work in any way. – gbetous Jan 04 '15 at 18:36
  • 1
    The `GIT_SSH` setting is definitely used by `git clone`s that happen over SSH. The problem with the above is probably that the `$HOME/bin/trickle-ssh.sh` script is buggy: it throws away the SSH arguments! I'll edit the answer and fix it ... – ntc2 Sep 24 '15 at 22:21