On Mon, Apr 02 2018, Yubin Ruan wrote: > I am writing to ask that whether or not you think will be appropriate to add > an option to "git clone" so that whenever a repo is cloned, branches are > created automatically to track corresponding remote branches. (or is there any > equivelant option?) > > You can obviously do this by a bash command like this > > git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done Aside from this specific suggestion, we should be careful when adding more special snowflakes to git-clone that aren't available through git-fetch or via after the fact config, such as git clone --single-branch which has no fetch equivalent (i.e. in finding out what the remote HEAD is). Actually now that I mention that it occurs to me that what you want could just be a special case of generalizing our existing --single-branch feature. I.e. we would clone repos as: [remote "origin"] url = git@xxxxxxxxxx:git/git.git fetch = +refs/heads/*:refs/remotes/origin/* branch = $symref(HEAD):refs/remotes/origin/HEAD:TRACK Or some other such syntax to create a refs/heads/master from the remote HEAD symref if it doesn't exist (note the lack of a +), then for your feature: branch = refs/heads/*:refs/remotes/origin/*:TRACK But you could also do: branch = +refs/heads/origin/*:refs/remotes/origin/*:TRACK Or whatever. I don't know what syntax would be sensible, but something like this is a missing feature of our existing --single-branch feature, and because of that you can only get its semantics by re-cloning.