2

I want to clone only a specific branch of a non bare repo to create a bare repo. So basically, from the git repo, I will do a git clone repo.git which will clone the existing repo and create a new folder repo.git. On doing a git branch in the new repo, it has the same branch as the old repo had (say master). Is there a way I can specify the branch while cloning so that the bare repo has that branch?

  • 1
    Possible duplicate of [How to clone a single branch in git?](http://stackoverflow.com/questions/1778088/how-to-clone-a-single-branch-in-git) – Tim Biegeleisen Nov 16 '16 at 04:20
  • you want to clone an existing branch, but keep it empty? you plan on committing future code to the same repo you cloned from? – matias elgart Nov 16 '16 at 04:22

1 Answers1

0

git clone will clone the HEAD set in remote repository (usually it is set to master branch) to local.

you can run git clone repo.git -b xxxx to specify which branch to clone to your local.

gzh
  • 3,507
  • 2
  • 19
  • 23