Cloning large repositories
When you want to clone a large git repository locally, consider using:
git clone --filter blob:none <the_remote_repository>
This is so much better than --depth 1! Instead, this method still gives you the full commit history but only downloads the file contents on demand, as they are needed.
Initially, only the files appearing in the last revision of the default branch are downloaded (to make the first checkout).
You can checkout any other revision and Git will download the necessary files from the origin on demand. Or run any other Git command, like git diff between commits you haven’t checked out yet.
Mind blown. Thanks to Théo Zimmermann for pointing me to that!
See the documentation of this --filter option for more details.
P.S.: running git blame with this set up is not optimal, as versions of the file are fetched one by one. But it still works! Maybe there is some optimization to do in this case.