Make Better Things



I like to make better things.

Clone a Git repo without history (just latest commit)

One common problem with big git repos is it takes a lot of time to clone, because in cloning git download everything beginning form the first commit. Sometimes we don’t need that much of history with code.

We can use “–depth” option in “git clone” command to specify how many commits we need. By providing an argument of “–depth 1″ to the clone command, the process will copy only the latest revision of everything in the repository.

For example -

git clone --depth 1 https://github.com/jquery/jquery.git jquery

This command only clones the HEAD of the jqueyr repository.

Note: Prior to git 1.9 we can’t use do pull or push on such repos.

Category: git

Tagged: , , ,

Leave a Reply