git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] clone: add a --no-tags option to clone without tags

From
BWBrandon Williams <bmwill@google.com>
Date
Apr 18, 2017, 23:30 UTC
Message-ID
<20170418233030.GA41018@google.com>
In-Reply-To
<20170418191553.15464-1-avarab@gmail.com>
On 04/18, Ævar Arnfjörð Bjarmason wrote:
Show 49 quoted lines
> Add a --no-tags option to "git clone" to clone without tags. Currently
> there's no easy way to clone a repository and end up with just a
> "master" branch via --single-branch, or track all branches and no
> tags. Now --no-tags can be added to "git clone" with or without
> --single-branch to clone a repository without tags.
> 
> Before this the only way of doing this was either by manually tweaking
> the config in a fresh repository:
> 
>     git init git &&
>     cat >git/.git/config <<EOF &&
>     [remote "origin"]
>         url = git@github.com:git/git.git
>         tagOpt = --no-tags
>         fetch = +refs/heads/master:refs/remotes/origin/master
>     [branch "master"]
>         remote = origin
>         merge = refs/heads/master
>     EOF
>     cd git &&
>     git pull
> 
> Which requires hardcoding the "master" name, which may not be the same
> branch, or alternatively by setting tagOpt=--no-tags right after
> cloning & deleting any existing tags:
> 
>     git clone --single-branch git@github.com:git/git.git &&
>     cd git &&
>     git config remote.origin.tagOpt --no-tags &&
>     git tag -l | xargs git tag -d
> 
> Which of course was also subtly buggy if --branch was pointed at a
> tag, leaving the user in a detached head:
> 
>     git clone --single-branch --branch v2.12.0 git@github.com:git/git.git &&
>     cd git &&
>     git config remote.origin.tagOpt --no-tags &&
>     git tag -l | xargs git tag -d
> 
> Now all this complexity becomes the much simpler:
> 
>     git clone --single-branch --no-tags git@github.com:git/git.git
> 
> Or in the case of cloning a single tag "branch":
> 
>     git clone --single-branch --branch v2.12.0 --no-tags git@github.com:git/git.git
> 
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
Patch seems sane to me.
-- 
Brandon Williams
Previous: Ævar Arnfjörð BjarmasonNext: Junio C Hamano
Message 4 of 11 in “Is there a way to get 'git fetch --no-tags' semantics with 'git clone'?”
  1. Ævar Arnfjörð BjarmasonApr 14, 2017
  2. clone: add a --no-tags option to clone without tagsÆvar Arnfjörð Bjarmason, Apr 18, 2017
  3. Ævar Arnfjörð BjarmasonApr 18, 2017
  4. Brandon WilliamsApr 18, 2017
  5. Junio C HamanoApr 19, 2017
  6. Junio C HamanoApr 19, 2017
  7. clone: add a --no-tags option to clone without tagsÆvar Arnfjörð Bjarmason, Apr 19, 2017
  8. Jonathan NiederApr 25, 2017
  9. Junio C HamanoApr 26, 2017
  10. Ævar Arnfjörð BjarmasonApr 26, 2017
  11. Jonathan NiederApr 25, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.