# is there a way to reference the branch point?

3 messages from 2010-01-29 to 2010-02-03. Participants: layer, Sverre Rabbelier.
Thread: https://gitlist.dev/t/22443

## layer, 2010-01-29 22:29

Subject: is there a way to reference the branch point?
Message-ID: <18219.1264804157@relay.known.net>
URL: https://gitlist.dev/e/18219.1264804157%40relay.known.net

```
If I make a branch `foo' off master, commit a bunch of times, is there
a way to reference the place on master from which I branched?

Thanks.

Kevin

```

## Sverre Rabbelier, 2010-01-29 22:35

Subject: Re: is there a way to reference the branch point?
Message-ID: <fabb9a1e1001291435p59599f62hd54cbca66d91c24b@mail.gmail.com>
URL: https://gitlist.dev/e/fabb9a1e1001291435p59599f62hd54cbca66d91c24b%40mail.gmail.com
In-Reply-To: <18219.1264804157@relay.known.net>

```
Heya,

On Fri, Jan 29, 2010 at 23:29, layer <layer@known.net> wrote:
> If I make a branch `foo' off master, commit a bunch of times, is there
> a way to reference the place on master from which I branched?

Depends, if you make a new branch from master, you can use 'git merge-base', so:

$ # on master
$ git checkout -b foo-topic-branch
$ # work work
$ git commit
$ # work work
$ git commit

Now you want to know where you branches off from master:

$ git merge-base foo-topic-branch master

That will show you the commit you branches off from, even if master
has grown new commits since then.

-- 
Cheers,

Sverre Rabbelier

```

## layer, 2010-02-03 21:40

Subject: Re: is there a way to reference the branch point?
Message-ID: <8481.1265233259@relay.known.net>
URL: https://gitlist.dev/e/8481.1265233259%40relay.known.net
In-Reply-To: <fabb9a1e1001291435p59599f62hd54cbca66d91c24b@mail.gmail.com>

```
Sverre Rabbelier <srabbelier@gmail.com> wrote:

>> Heya,
>> 
>> On Fri, Jan 29, 2010 at 23:29, layer <layer@known.net> wrote:
>> > If I make a branch `foo' off master, commit a bunch of times, is there
>> > a way to reference the place on master from which I branched?
>> 
>> Depends, if you make a new branch from master, you can use 'git
>> merge-base', so:
>> 
>> $ # on master
>> $ git checkout -b foo-topic-branch
>> $ # work work
>> $ git commit
>> $ # work work
>> $ git commit
>> 
>> Now you want to know where you branches off from master:
>> 
>> $ git merge-base foo-topic-branch master
>> 
>> That will show you the commit you branches off from, even if master
>> has grown new commits since then.

That works, but what if I don't know it's off master?  Normally, a
human would, but what if this is a script I'm writing?

Thanks.

Kevin

```
