Each of us frequently employs the “git clone” command in our daily routines, particularly when seeking open source projects.
In this article, I aim to demonstrate how the “allow” parameter can help minimize bandwidth usage when downloading a repository from a remote source.
Normal version
Directory size: 50 Megabyte
1 2 3 4 5 6 7 8 9 10 11 12 |
$ git clone https://github.com/org-roam/org-roam-server Cloning into 'org-roam-server'... remote: Enumerating objects: 83, done. remote: Counting objects: 100% (83/83), done. remote: Compressing objects: 100% (58/58), done. remote: Total 436 (delta 47), reused 55 (delta 25), pack-reused 353 Receiving objects: 100% (436/436), 37.66 MiB | 10.73 MiB/s, done. Resolving deltas: 100% (265/265), done. Checking connectivity... done. $ du -sh org-roam-server 50M org-roam-server |
Depth version
Directory size: 22 Megabyte
1 2 3 4 5 6 7 8 9 10 11 12 |
$ git clone --depth 1 https://github.com/org-roam/org-roam-server Cloning into 'org-roam-server'... remote: Enumerating objects: 18, done. remote: Counting objects: 100% (18/18), done. remote: Compressing objects: 100% (18/18), done. remote: Total 18 (delta 1), reused 12 (delta 0), pack-reused 0 Unpacking objects: 100% (18/18), done. Checking connectivity... done. $ du -sh org-roam-server 22M org-roam-server |
You can copy the aliases which at below to your .bashrc or implement same mechanism to your CI/CD pipeline.
1 2 3 |
# This commands always clone master branch. If you want another branch check the manual alias gc='git clone' alias gcd='git clone --depth 1' |
Daha fazlası için
- https://www.perforce.com/blog/vcs/git-beyond-basics-using-shallow-clones
- More information is here
- https://community.atlassian.com/t5/Bitbucket-questions/clone-depth-does-what-Why-do-I-care-about-this-setting/qaq-p/496247
- https://git-scm.com/docs/git-clone
- git-clone man page
- https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/
- Nice one