Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .