threads / discuss / 22443

is there a way to reference the branch point?

Subject: is there a way to reference the branch point?

## tl;dr

3 messages between Jan 29, 2010 and Feb 3, 2010.

replies: 2people: 2as markdown or json

layer· Jan 29, 2010, 22:29 UTC · lore

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· Jan 29, 2010, 22:35 UTC · re: layer · lore

Re: is there a way to reference the branch point?

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· Feb 3, 2010, 21:40 UTC · re: Sverre Rabbelier · lore

Re: is there a way to reference the branch point?

Sverre Rabbelier <srabbelier@gmail.com> wrote:
Show 22 quoted lines
>> 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

← back to recent threads