github has a download button which offers a download for .tar.gz and .zip files. Essentially i want the same thing for the latest branch or of a tag. I dont want to work on the project, i just want to compile it. How do i get the source only of any git repo?

link|improve this question

55% accept rate
feedback

2 Answers

up vote 5 down vote accepted

What you need is a shallow clone:

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.


git clone --depth 1 /path/to/repo.git

Will result in a Shallow clone of the repo with the current revision only.

link|improve this answer
feedback

Use git archive; something like:

git archive --format=tar --remote=$REPO $BRANCH | tar xf -

This command gets only the source tree with no git metadata (i.e., no .git subdirectory). It is also very fast. The command above writes the source code into the current directory; to write it into a subdirectory add the option --prefix=subdir/.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.