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

4 messages from 2012-06-22 to 2012-06-22. Participants: ryenus, Ævar Arnfjörð Bjarmason, Junio C Hamano, Neal Kreitzinger.
Thread: https://gitlist.dev/t/30869

## ryenus, 2012-06-22 14:58

Subject: [RFE] option for find branches in a remote repo which contain a certain commit
Message-ID: <CAKkAvazRfb0kTphLKoRQxSEBZwHfVZeaM0xEbcxEw7Mt5RMg8A@mail.gmail.com>
URL: https://gitlist.dev/e/CAKkAvazRfb0kTphLKoRQxSEBZwHfVZeaM0xEbcxEw7Mt5RMg8A%40mail.gmail.com
In-Reply-To: <CAKkAvazNqZWk=QRmSFsFL33M6z+nZZ_yyxxbxwAh=fQk5DVt-Q@mail.gmail.com>

```
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, 2012-06-22 15:24

Subject: Re: [RFE] option for find branches in a remote repo which contain a certain commit
Message-ID: <CACBZZX6nbWCFWWy5NTMSAPOf4RHUAbC9TuffPPy=2Ehn7KSnaA@mail.gmail.com>
URL: https://gitlist.dev/e/CACBZZX6nbWCFWWy5NTMSAPOf4RHUAbC9TuffPPy%3D2Ehn7KSnaA%40mail.gmail.com
In-Reply-To: <CAKkAvazRfb0kTphLKoRQxSEBZwHfVZeaM0xEbcxEw7Mt5RMg8A@mail.gmail.com>

```
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, 2012-06-22 18:14

Subject: Re: [RFE] option for find branches in a remote repo which contain a certain commit
Message-ID: <7vtxy3p61o.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vtxy3p61o.fsf%40alter.siamese.dyndns.org
In-Reply-To: <CACBZZX6nbWCFWWy5NTMSAPOf4RHUAbC9TuffPPy=2Ehn7KSnaA@mail.gmail.com>

```
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:

> 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, 2012-06-22 18:52

Subject: Re: [RFE] option for find branches in a remote repo which contain a certain commit
Message-ID: <4FE4BEDA.20608@gmail.com>
URL: https://gitlist.dev/e/4FE4BEDA.20608%40gmail.com
In-Reply-To: <CACBZZX6nbWCFWWy5NTMSAPOf4RHUAbC9TuffPPy=2Ehn7KSnaA@mail.gmail.com>

```
On 6/22/2012 10:24 AM, Ævar Arnfjörð Bjarmason wrote:
> 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

```
