{"id":15460478,"url":"https://github.com/schollz/git","last_synced_at":"2026-02-05T22:04:33.752Z","repository":{"id":57545669,"uuid":"131914483","full_name":"schollz/git","owner":"schollz","description":"Force `go get` to make shallow clone and pulls","archived":false,"fork":false,"pushed_at":"2018-05-03T12:06:06.000Z","size":5,"stargazers_count":11,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-19T10:42:23.178Z","etag":null,"topics":["git","go-get","golang","tools"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/schollz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-02T22:59:20.000Z","updated_at":"2024-11-19T14:05:33.000Z","dependencies_parsed_at":"2022-09-26T18:40:34.243Z","dependency_job_id":null,"html_url":"https://github.com/schollz/git","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/schollz/git","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schollz%2Fgit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schollz%2Fgit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schollz%2Fgit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schollz%2Fgit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/schollz","download_url":"https://codeload.github.com/schollz/git/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schollz%2Fgit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29135950,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-05T21:59:57.939Z","status":"ssl_error","status_checked_at":"2026-02-05T21:59:57.628Z","response_time":65,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["git","go-get","golang","tools"],"created_at":"2024-10-01T23:22:04.503Z","updated_at":"2026-02-05T22:04:33.690Z","avatar_url":"https://github.com/schollz.png","language":"Go","readme":"# How to use shallow clones for `go get`\n\nThis is a little hack to use shallow clones for new git checkouts with `go get`. Unfortunately for Gophers, [this has been an open issue for three years counting](https://github.com/golang/go/issues/13078) without a workable solution aside from patching the go toolchain yourself. This solution utilizes a *git* wrapper that determines if a pull/clone is happening and then makes sure it is shallow. \n\nTo install it you do \n\n```\n$ go get github.com/schollz/git\n```\n\nThe *git*-wrapper tool is named *\"git\"* on purpose so that your GOPATH can be prepended to the PATH and then the *git*-wrapper substituted for the real *git* (`/usr/bin/git`). So then, to activate shallow cloning all you have to do is: \n\n```\n$ export PATH=$GOPATH/bin:$PATH\n```\n\nwhich you can add to your `.bashrc` files if you want it to be permanent. This way, the wrapper will aways be used and the wrapper will force cloning to be shallow.\n\n# Benchmarks\n\nHere's a benchmark showing a 50% reduction in disk usage and thus a 50% reduction in time taken for a `go get`. You'll not get that much for smaller repositories, but its not bad.\n\n## normal `go get`\n\n\n```\n% docker run -it golang:1.10 /bin/bash\nroot@d9208178f1fa:/go# time go get github.com/juju/juju/...\nreal    7m35.631s\nuser    1m40.059s\nsys     0m45.436s\nroot@d9208178f1fa:/go# du -sh .\n1.1G\n```\n\n## shallow `go get`\n\n```\n% docker run -it golang:1.10 /bin/bash\nroot@68135fb64a3e:/go# go get github.com/schollz/git\nroot@68135fb64a3e:/go# export PATH=$GOPATH/bin:$PATH\nroot@68135fb64a3e:/go# time go get github.com/juju/juju/...\nreal    3m0.335s\nuser    0m29.192s\nsys     0m17.253s\nroot@d9208178f1fa:/go# du -sh .\n499M    .\n```\n\n# Acknowledgements\n\nThanks [tscholl2](https://github.com/tscholl2) for the idea.\n\n# License\n\nMIT","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschollz%2Fgit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fschollz%2Fgit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschollz%2Fgit/lists"}