Git clone will behave copying remote current working branch into local. Is there any way to clone a specific branch by myself without switching branches on remote repo? Thanks
+2
A:
git init
git remote add add -t refspec remotename host:/dir.git
git fetch
But IIRC, by default clone fetches all branches from remote, not current working branch.
Michael Krelin - hacker
2009-12-15 23:09:29
Thanks. I figured out using below method.git clone <remote_repo>git checkout -b <wanted_branch> origin/<wanted_branch>git branch -D master
Scud
2009-12-16 00:05:58
That's awesome -- I didn't realize you could specify just a single refspec like that. But did you mean "git remote add origin -t refspec etc..."?
ebneter
2009-12-16 00:37:29
I think so, and you will get [remote "origin"] fetch = +refs/heads/(refspec):refs/remotes/origin/(refspec) instead of fetch = +refs/heads/*:refs/remotes/origin/*
Scud
2009-12-16 01:54:35
ebneter, yes, I forgot the "remote" section name.
Michael Krelin - hacker
2009-12-16 08:23:28
Scud, honestly, I prefer `vim .git/config` for these needs. This way I sure know what am I to get ;-)
Michael Krelin - hacker
2009-12-16 08:24:32