Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git - only fetch the files, not the history

when I am running git pull or git fetch, I obviously retrieve both history and files. For huge projects, that takes very much time. I wonder how this process could be sped up, as for some projects I am only interested in the source code and not in the history. Is there a way to tell git that I only want to fetch the current snapshot of the files and not the whole history as well?

like image 658
Max Beikirch Avatar asked Apr 15 '13 08:04

Max Beikirch


1 Answers

You probably want to look at the --depth option in git clone--called a "shallow clone". In particular, you probably want:

git clone --depth=1 <url>

If the project is on GitHub, you can always use the download links from there. Note, there are some catches to using a shallow clone:

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.

But that sounds like something you can live with.

Also, as positron pointed out, you can do this with git archive as well.

like image 108
John Szakmeister Avatar answered Oct 04 '22 22:10

John Szakmeister