Get the latest tech news

Git clone –depth 2 is vastly better than –depth 1 if you want to Git push later


I've done a shallow clone of a large repo (git clone --depth 1 git@github.com:myOrg/myRepo.git). I can push new changes to the remote but the first push is horribly slow. Subsequent pushes are fine...

In all of these cases, then, we can—as Git always does—start at the tip and work backwards and eventually arrive at the root. They receive it all, unpack it, find that we've duplicated 99% of what they already have, ignore the extra copies, and take the new commit and put it in their repository: Given that you intend to run git push, you'll get a lot of mileage out of having one un-mangled commit "between" the shallow graft point and a branch tip.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of depth

depth

Photo of Git

Git

Related news:

News photo

jj: a Git-compatible VCS that is both simple and powerful

News photo

Beej's Guide to Git

News photo

Clone2Leak attacks exploit Git flaws to steal credentials