Web lists-archives.com

Re: Command to list <pattern> Branches on a specific Remote (i.e. select from rtb's)




On Sat, May 18 2019, Philip Oakley wrote:

> Hi,
> I'm unsure if there is a command for this.
>
> Currently I have 1600+ remote tracking branches (rtb) for my Git repo
> as it covers both git.git and git-for-windows and some other
> contributors.
>
> Finding a specific rtb for a particular remote looks like there ought
> to be a simple command ready to do the job, but I haven't found
> anything.
>
> Is there a command or simple simple invocation of branch, show-ref,
> for-each-ref, etc that can be give a branch pattern and remote name to
> quickly filter down the list of potential branches to just one or two
> 24-line screens?

That's:

    git for-each-ref 'refs/remotes/<remote>/<pattern>'
    git branch -a -l '<remote>/<pattern>'

The latter will conflate <remote> with any local branches you happen to
have prefixed with <remote>.

The reason this isn't some easy mode in some command is because there's
no hard notion that a given remote "owns" a given set of RTB's. It's
just convention, but they can and do overlap sometimes.

See the logic in 'git remote remove' that needs to decide if a deletion
of a remote should delete its remote tracking refs: 7ad2458fad ("Make
"git-remote rm" delete refs acccording to fetch specs", 2008-06-01)