Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 6 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.

share|improve this answer

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/.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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