How to clone a snapshot of a remote repository at a specific branch?

I know that one can make a zip of the current branch by:

git archive -o archive.zip HEAD

However, at situations, one may want to clone a copy/snapshot of remote repository at a specific branch because:

1) The repository is large with long history and cloning the whole history takes too much time.

2) What I want is a specific branch's "snapshot" not the master branch's.

asked Jul 24, 2014 by Eric Z Ma (44,280 points)

1 Answer

 
Best answer

To take a snapshot (no history, only files at HEAD) from branch br1 from git@git.example.com:repo:

git clone -b br1 git@git.example.com:repo --depth 1

-b br1 makes git clone the branch br1.

--depth 1 makes git only fetch the history of depth 1

answered Jul 24, 2014 by Eric Z Ma (44,280 points)

Please log in or register to answer this question.

Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost

...