git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Yubin Ruan <ablacktshirt@gmail.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [RFC] git clone add option to track all remote branches
Date: Mon, 02 Apr 2018 11:29:41 +0200	[thread overview]
Message-ID: <874lkuvtve.fsf@evledraar.gmail.com> (raw)
In-Reply-To: <20180402015035.mzgye6apwn3igch5@HP>


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@github.com: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.

      parent reply	other threads:[~2018-04-02  9:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-02  1:50 [RFC] git clone add option to track all remote branches Yubin Ruan
2018-04-02  2:56 ` Junio C Hamano
2018-04-02  3:21   ` Junio C Hamano
2018-04-02  3:45     ` Randall S. Becker
2018-04-02  9:29 ` Ævar Arnfjörð Bjarmason [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874lkuvtve.fsf@evledraar.gmail.com \
    --to=avarab@gmail.com \
    --cc=ablacktshirt@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).