threads / discuss / 30869

[RFE] option for find branches in a remote repo which contain a certain commit

Subject: [RFE] option for find branches in a remote repo which contain a certain commit

## tl;dr

4 messages between Jun 22, 2012 and Jun 22, 2012.

replies: 3people: 4as markdown or json

ryenus· Jun 22, 2012, 14:58 UTC · lore

Given a certain commit, I want there's a command/option for git to make it search the remote repo (e.g. origin) and tell me the branches there which contain that commit.

So that I can pick the wanted branch and fetch it afterward.

The reason I need this is that there are hundreds of (could be more) branches, but I just need a few of them, and don't want to fetch all other branches.

I guess this could be an option for git-remote, so that with a given remote and commit, it returns a list of branches (or even tags). The list size might default to a number and should be customizable.

Thanks
Ævar Arnfjörð Bjarmason· Jun 22, 2012, 15:24 UTC · re: ryenus · lore

Re: [RFE] option for find branches in a remote repo which contain a certain commit

On Fri, Jun 22, 2012 at 4:58 PM, ryenus <ryenus@gmail.com> wrote:
> Given a certain commit, I want there's a command/option for git to
> make it search the remote repo (e.g. origin) and tell me the
> branches there which contain that commit.

git branch --contains <commit> git branch -a --contains <commit> git tag --contains <commit>

Junio C Hamano· Jun 22, 2012, 18:14 UTC · re: Ævar Arnfjörð Bjarmason · lore

Re: [RFE] option for find branches in a remote repo which contain a certain commit

Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
Show 8 quoted lines
> On Fri, Jun 22, 2012 at 4:58 PM, ryenus <ryenus@gmail.com> wrote:
>> Given a certain commit, I want there's a command/option for git to
>> make it search the remote repo (e.g. origin) and tell me the
>> branches there which contain that commit.
>
> git branch --contains <commit>
> git branch -a --contains <commit>
> git tag --contains <commit>

Yes and no. These are all local operations, so you would need to do a "git clone" before starting to dig history like that.

Neal Kreitzinger· Jun 22, 2012, 18:52 UTC · re: Ævar Arnfjörð Bjarmason · lore

Re: [RFE] option for find branches in a remote repo which contain a certain commit

On 6/22/2012 10:24 AM, Ævar Arnfjörð Bjarmason wrote:
Show 9 quoted lines
> On Fri, Jun 22, 2012 at 4:58 PM, ryenus <ryenus@gmail.com> wrote:
>> Given a certain commit, I want there's a command/option for git to
>> make it search the remote repo (e.g. origin) and tell me the
>> branches there which contain that commit.
>
> git branch --contains <commit>
> git branch -a --contains <commit>
> git tag --contains <commit>
>
 >> ...The reason I need this is that there are hundreds of...
 >> branches, but I just need a few of them, and don't want to fetch all
 >> other branches...
You could have a 'query repo' that is a local clone of the remote repo.
  Fetch all branches to the local query repo and then use AEvar's
suggested commands.  Once you find the branches you want then you can 
git remote add -t them.

v/r, neal

← back to recent threads