I have a local git repository called 'skeleton' that I use for storing project skeletons. It has a few branches, for different kinds of projects:
casey@agave [~/Projects/skeleton] git branch
casey@agave [~/Projects] git clone skeleton new
Initialized empty Git repository in /Users/casey/Projects/new/.git/
Note: the git1.7.10 (April 2012) actually allows you to clone only one branch:
# clone only the remote primary HEAD (default: origin/master) git clone --single-branch as in: git clone <url> --branch <branch> --single-branch [<folder>]
You can see it in
test_expect_success 'single branch clone' ' git clone --single-branch "file://$(pwd)/." singlebranch '
This is implicit when doing a shallow clone.
git clone --depth 1the easiest way to save bandwidth.
And since Git 1.9.0 (February 2014), shallow clones support data transfer (push/pull), so that option is even more useful now.
See more at "Is
git clone --depth 1 (shallow clone) more useful than it makes out?".
"Undoing" a shallow clone is detailed at "Convert shallow clone to full clone" (git 1.8.3+)
# unshallow the current branch git fetch --unshallow # for getting back all the branches (see Peter Cordes' comment) git config remote.origin.fetch refs/heads/*:refs/remotes/origin/* git fetch --unshallow