question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

git checkout could/should be done with --depth=1

See original GitHub issue

pip can install directly from git, great!

When pip installs from git, it downloads the entire history of the git branch - when all it wants is the target version. I believe this can be achieved using the --depth=1 flag to various git subcommands. The speedup on projects with a long history can be significant.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:24
  • Comments:55 (31 by maintainers)

github_iconTop GitHub Comments

9reactions
naught101commented, Mar 7, 2017

For anyone using pip git installs a lot right now, who can’t wait, and who doesn’t care about setuptools_scm, you can just hack this this as a work-around. Just replace line 142 in <python-lib-path>/pip/vcs/git.py:

            self.run_command(['clone', '-q', url, dest])

with

            self.run_command(['clone', '--depth=1', url, dest])

Dodgy, but it saves me 20 minutes on a statsmodel install…

7reactions
mrmachinecommented, Mar 31, 2017

@dstufft caching entire repos does not solve the underlying motivation for this, at least for me. I use Docker a lot these days, and build a lot of projects in Docker images that often pip install editable requirements (because for example, you must make a requirement editable to include in a requirements.in file for use with pip-tools (which admittedly is not really pip’s problem, but we need to use it to work around some other pip limitations e.g. “first-found” nested dependency conflict resolution).

I don’t want or need to download let alone bake into the image, the entire 25,000 commit, 220 MB Django repository, for example.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How and when to perform a git clone depth 1 example
How to do a git clone of depth 1 · Copy the clone URL of the remote repository; · Include the –depth 1...
Read more >
Using GIT to get another branch when the clone was done with
Because --depth 1 implies --single-branch , you got only one commit for one branch. Use the --no-single-branch option during cloning to get one...
Read more >
How to Use Git Shallow Clone to Improve Performance
Provide an argument of -- depth 1 to the git clone command to copy only the latest revision of a repo: git clone...
Read more >
Git Shallow Clone and Clone Depth - Linux Hint
Git's solution to the problem is shallow clone where you can use clone depth to define how deep your clone should go. For...
Read more >
Git - git-clone Documentation
Employ a sparse-checkout, with only files in the toplevel directory initially being present. The git-sparse-checkout[1] command can be used to grow the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found