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

Re: git branch <refspec>

From
ZHZenaan Harkness <zen@freedbms.net>
Date
Jun 2, 2015, 10:22 UTC
Message-ID
<CAOsGNSQistVzM5vqueOUku9ZOR5dTOFJEtb8X1VwRezLr692Gw@mail.gmail.com>
In-Reply-To
<CAOsGNSTtWnawxmpL7SByUBZ-XUNdDd5nKNuudGQi-S3BjCHcdg@mail.gmail.com>
On 6/2/15, Zenaan Harkness <zen@freedbms.net> wrote:
Show 17 quoted lines
> <refspec> - git's guilty little secret. Let's milk the guilt.
>
> git branch <refspec> ought work in a similar way to
> git fetch <refspec>
>
> One syntax to rule them all. Or something.
>
> I just learned how git fetch uses refspecs and how this can just as
> well apply to tags to create "remote tags" (refs/rtags/remote_name/*),
> finally grokking the ridiculously simple yet powerful refspec concept
> - it really is generic.
>
> And now combining two remotes such as postgresql and postgresql-xc
> (which share substantial code and parent commits), or (a bit out of
> date now, but) the openmoko-kernel and linux mainline, becomes
> simpler/saner when "inventing" rtags as explained here:
> http://stackoverflow.com/questions/22108391/git-checkout-a-remote-tag
Regarding this stackoverflow article and "rtags", what I'm now doing
is, for postgresql mainline "origin" and postresql-xc "pgxc" remotes:
[remote "origin"]
  url = git://git.postgresql.org/git/postgresql.git
  fetch = +refs/*:refs/*
  fetch = +refs/*:refs/remotes/origin/*
[remote "pgxc"]
  url = https://github.com/postgres-x2/postgres-x2.git
  fetch = +refs/*:refs/remotes/origin/*

so that origin is my normal --mirror, but also with origin and pgxc having everything (!) under refs/remotes/$name/*

This allows for those who want multiple related remotes in the one mirror to include 'interesting' refs from each remote in a way that does not clash, e.g. github's refs/pull/* pull requests.

This only leads to the "how to minimize typing without extra porcelain", and of course a symlink here can help: cd refs/ ln -s remotes r

or perhaps even better : ln -s remotes/* .

Using +refs/*:refs/remotes/origin/* feels better than e.g.: refs/rtags/origin/* refs/rpull/origin/* refs/rtags/pgxc/* refs/rpull/pgxc/* refs/blah?/origin/* refs/blah?/pgxc/* althogh these forms might simplify porcelain (e.g. tab completion) which needs to work with all refs of a particular 'type'.

Zenaan
Previous: Zenaan Harkness
Message 2 of 2 in “git branch <refspec>”
  1. Zenaan HarknessJun 2, 2015
  2. Zenaan HarknessJun 2, 2015

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.