Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quick "git clone" from remote repository?

I'm new to Git. Starting work on any project seems to start with a "git clone". But this seems to take a long time - much longer than the equivalent "svn checkout". Is this because the entire history of the project since the dawn of time is being copied? Is it possible to skip the history, and just get the latest files (but retain repository information, allowing future pulls etc).

like image 381
Steve Bennett Avatar asked Sep 03 '11 13:09

Steve Bennett


People also ask

How do I clone a remote git repository?

To Git clone a repository navigate to your preferred repository hosting service like GitHub, select the repository you want to clone, copy the repository URL via HTTPS or SSH, type git clone in the command line, paste the URL, and hit enter .

How do I speed up git clone?

Simple solution: git shallow clone The first solution to a fast clone and saving developer's and system's time and disk space is to copy only recent revisions. Git's shallow clone option allows you to pull down only the latest n commits of the repo's history.


2 Answers

You can use git clone --depth=$NUM_REVISIONS, which has the following caveats:

Create a shallow clone with a history truncated to the specified number of revisions. A shallow repository has a number of limitations (you cannot clone or fetch from it, nor push from nor into it), but is adequate if you are only interested in the recent history of a large project with a long history, and would want to send in fixes as patches.

like image 180
Mark Rushakoff Avatar answered Sep 21 '22 04:09

Mark Rushakoff


No, it's not possible. If you want to participate in a repository's history, you must have the entire history to build from. While it does take a bit longer than an SVN checkout, it's still quite fast unless you're doing it over a slow connection and/or have a really huge project.

like image 45
Ryan Stewart Avatar answered Sep 22 '22 04:09

Ryan Stewart