threads / rfc / 33827

[RFC] New kind of upstream branch: base branch

Subject: [RFC] New kind of upstream branch: base branch

## tl;dr

14 messages between May 15, 2013 and May 19, 2013.

replies: 13people: 5as markdown or json

Felipe Contreras· May 15, 2013, 20:34 UTC · lore
Hi,

I've been using Git from the start, but only lately have I forced myself to configure upstream branches for all my branches, and I've found a few things more convenient, but others completely contrary to what I expected.

Inconvenient:

Before, I used to do 'git fetch' to simply fetch from 'origin', but now, it depends on where 'upstream' is set to.

Convinient:

Now, I can just do 'git rebase --interactive' and I don't have to specify the starting point, which is particularily useful when there's a lot of branches one depending on another.

I think I'm using 'upstream' for something it was not intended to, and I think the current 'upstream' behavior should be split into 'upstream' and 'base'.

== base ==

The 'base' branch will be set each time you create a branch from another; 'git checkout -b foobar master' sets 'master' as the 'base' of 'foobar'.

Then you can do 'git rebase foobar@{base}' or simply 'git rebase', and Git will pick the right branch to rebase unto, even if you have no 'upstream' configured.

This way 'git fetch' will keep picking 'origin', and other commands that make use of 'upstream' would be undisturbed.

If both 'base' and 'upstream' are defined, I think 'git rebase' should use 'base', but since that would break old behavior, perhaps there should be a configuration variable to enable a different behavior.

I already started writting the patches, and although tedious, I think they they'll be rather straightforward, but I thought it would be best to hear some opinions first.

What do you think?
-- 
Felipe Contreras
Philip Oakley· May 15, 2013, 22:22 UTC · re: Felipe Contreras · lore

Re: [RFC] New kind of upstream branch: base branch

From: "Felipe Contreras" <felipe.contreras@gmail.com>
Sent: Wednesday, May 15, 2013 9:34 PM
Show 49 quoted lines
> Hi,
>
> I've been using Git from the start, but only lately have I forced
> myself to configure upstream branches for all my branches, and I've
> found a few things more convenient, but others completely contrary to
> what I expected.
>
> Inconvenient:
>
> Before, I used to do 'git fetch' to simply fetch from 'origin', but
> now, it depends on where 'upstream' is set to.
>
> Convinient:
>
> Now, I can just do 'git rebase --interactive' and I don't have to
> specify the starting point, which is particularily useful when there's
> a lot of branches one depending on another.
>
> I think I'm using 'upstream' for something it was not intended to, and
> I think the current 'upstream' behavior should be split into
> 'upstream' and 'base'.
>
> == base ==
>
> The 'base' branch will be set each time you create a branch from 
> another;
> 'git checkout -b foobar master' sets 'master' as the 'base' of 
> 'foobar'.
>
> Then you can do 'git rebase foobar@{base}' or simply 'git rebase', and
> Git will pick the right branch to rebase unto, even if you have no
> 'upstream'
> configured.
>
> This way 'git fetch' will keep picking 'origin', and other commands
> that make use of 'upstream' would be undisturbed.
>
> If both 'base' and 'upstream' are defined, I think 'git rebase' should
> use 'base', but since that would break old behavior, perhaps there
> should be a configuration variable to enable a different behavior.
>
> I already started writting the patches, and although tedious, I think
> they they'll be rather straightforward, but I thought it would be best
> to hear some opinions first.
>
> What do you think?
>
> -- 
> Felipe Contreras

--- Sound a reasonable idea. On some patches I was working on I had to [chose to] add a tag for the base which made it easier to rebase later.

The other point is that I had already noted that the glossary doesn't include the many "base" terms in use that aren't always well understood.

Philip Oakley 
Felipe Contreras· May 16, 2013, 03:46 UTC · re: Philip Oakley · lore

Re: [RFC] New kind of upstream branch: base branch

On Wed, May 15, 2013 at 5:22 PM, Philip Oakley <philipoakley@iee.org> wrote:
> Sound a reasonable idea. On some patches I was working on I had to [chose
> to] add a tag for the base which made it easier to rebase later.
And was the 'upstream' branch somehow not appropriate for some reason?
-- 
Felipe Contreras
Philip Oakley· May 16, 2013, 19:35 UTC · re: Felipe Contreras · lore

Re: [RFC] New kind of upstream branch: base branch

From: "Felipe Contreras" <felipe.contreras@gmail.com>
Sent: Thursday, May 16, 2013 4:46 AM
Show 8 quoted lines
> On Wed, May 15, 2013 at 5:22 PM, Philip Oakley <philipoakley@iee.org> 
> wrote:
>
>> Sound a reasonable idea. On some patches I was working on I had to 
>> [chose
>> to] add a tag for the base which made it easier to rebase later.
>
> And was the 'upstream' branch somehow not appropriate for some reason?

If I remember correctly, I had a short branch based on 'pu', which was rewound, so I wanted to rebase that short branch onto the new 'pu'. This creates a confusion between old-pu and new-pu. Having a marker for the 'base' at the branch point allowed an easy specification of the branch

I think I misunderstood your proposal. I thought that it would effectively save a marker (e.g. the sha1) for the base point of the branch, it may have been something similar to a [lightweight] tag, it could have been just local or could have been transferable, I hadn't thought it further.

Philip 
Felipe Contreras· May 17, 2013, 00:07 UTC · re: Philip Oakley · lore

Re: [RFC] New kind of upstream branch: base branch

On Thu, May 16, 2013 at 2:35 PM, Philip Oakley <philipoakley@iee.org> wrote:
Show 17 quoted lines
> From: "Felipe Contreras" <felipe.contreras@gmail.com>
> Sent: Thursday, May 16, 2013 4:46 AM
>
>> On Wed, May 15, 2013 at 5:22 PM, Philip Oakley <philipoakley@iee.org>
>> wrote:
>>
>>> Sound a reasonable idea. On some patches I was working on I had to [chose
>>> to] add a tag for the base which made it easier to rebase later.
>>
>>
>> And was the 'upstream' branch somehow not appropriate for some reason?
>
>
> If I remember correctly, I had a short branch based on 'pu', which was
> rewound, so I wanted to rebase that short branch onto the new 'pu'. This
> creates a confusion between old-pu and new-pu. Having a marker for the
> 'base' at the branch point allowed an easy specification of the branch

So you were not doing 'git rebase @{base}', you were doing 'git rebase --onto X @{base}'?

> I think I misunderstood your proposal. I thought that it would effectively
> save a marker (e.g. the sha1) for the base point of the branch, it may have
> been something similar to a [lightweight] tag, it could have been just local
> or could have been transferable, I hadn't thought it further.

Yeah, I thought about that, and I think it might make sense, but that's another topic.

-- 
Felipe Contreras
Kevin Bracey· May 17, 2013, 19:20 UTC · re: Felipe Contreras · lore

Re: [RFC] New kind of upstream branch: base branch

On 15/05/2013 23:34, Felipe Contreras wrote:
Show 5 quoted lines
>   
> I think I'm using 'upstream' for something it was not intended to, and
> I think the current 'upstream' behavior should be split into
> 'upstream' and 'base'.
>

I found myself thinking the same thing. It's really convenient being able to set your topic branch's upstream to another local branch, so git rebase works without parameters. But then I can't use upstream to point to a remote version of that topic branch. I want my topic branch to know both that it's based on master (or origin/master), and that it's upstream is origin/topic.

So, yes, here's a vote in favour of the general concept.
Kevin
Junio C Hamano· May 17, 2013, 19:51 UTC · re: Kevin Bracey · lore

Re: [RFC] New kind of upstream branch: base branch

Kevin Bracey <kevin@bracey.fi> writes:
Show 8 quoted lines
> On 15/05/2013 23:34, Felipe Contreras wrote:
>>   I think I'm using 'upstream' for something it was not intended to,
>> and
>> I think the current 'upstream' behavior should be split into
>> 'upstream' and 'base'.
>>
> I found myself thinking the same thing. It's really convenient being
> able to set your topic branch's upstream to another local branch, so
What is that "another local branch"?

Is the use case "master forks from origin/master and has its own changes on top, and then topic builds on my master but the range of commits origin/master..topic includes both changes, that is inconvenient to when rebuilding topic on top of my master"?

I'd assume that it is the case, and the answer to the previous question is 'master' in the example.

> git rebase works without parameters. But then I can't use upstream to
> point to a remote version of that topic branch. I want my topic branch
> to know both that it's based on master (or origin/master), and that
> it's upstream is origin/topic.

If we do s/and that it's upstream is/and that it is pushed to/, then I think I am in general agreement (I wrote about it earlier in a separate message).

> So, yes, here's a vote in favour of the general concept.

Yes, you should be able to treat what you build on top (upstream) and where you publish the result (we are still looking for a better name in the other thread) as two distinct things in a triangular workflow. I agree that it is an issue we need to address.

We have solved a half ("push goes to a different repository") but not the other half ("updates a branch whose name is different from the upstream") in the upcoming 1.8.3 release.

The latest round of design from Felipe calls it branch.$name.push, if I am not mistaken.

I think it is somewhat an overkill, though.

It is normal for upstream's name not to match the topic's name (i.e. your 'topic' may branch off of a generic 'master', but would be named after a more specific purpose of the branch and is unlikely to be named 'master'. In other words, branch.$name.merge that points at an upstream that has a name that is totally different from $name is not an exception. So branch.$name.merge that you have to set for each branch is a necessity.

However, if you were to push out 'topic' directly (as opposed to pushing out a result of integrating it and other topic branches to your 'master') to your own publishing point, it is likely you would push it out to the same name (i.e. 'topic' will be pushed out as 'topic', not as 'master'). And if that is your workflow, setting push.default to "current" (and setting remote.pushdefault to your publishing repository) should be a sufficient interim solution, and you do not need to set branch.$name.push to each and every branch you intend to push out, I think.

Felipe Contreras· May 17, 2013, 20:15 UTC · re: Junio C Hamano · lore

Re: [RFC] New kind of upstream branch: base branch

On Fri, May 17, 2013 at 2:51 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 12 quoted lines
> Kevin Bracey <kevin@bracey.fi> writes:
>
>> On 15/05/2013 23:34, Felipe Contreras wrote:
>>>   I think I'm using 'upstream' for something it was not intended to,
>>> and
>>> I think the current 'upstream' behavior should be split into
>>> 'upstream' and 'base'.
>>>
>> I found myself thinking the same thing. It's really convenient being
>> able to set your topic branch's upstream to another local branch, so
>
> What is that "another local branch"?
refs/heads/*
> Is the use case "master forks from origin/master and has its own
> changes on top, and then topic builds on my master but the range of
> commits origin/master..topic includes both changes, that is
> inconvenient to when rebuilding topic on top of my master"?
No it's not. You just 'git rebase -i' and everything works.
Show 27 quoted lines
> I'd assume that it is the case, and the answer to the previous
> question is 'master' in the example.
>
>> git rebase works without parameters. But then I can't use upstream to
>> point to a remote version of that topic branch. I want my topic branch
>> to know both that it's based on master (or origin/master), and that
>> it's upstream is origin/topic.
>
> If we do s/and that it's upstream is/and that it is pushed to/, then
> I think I am in general agreement (I wrote about it earlier in a
> separate message).
>
>> So, yes, here's a vote in favour of the general concept.
>
> Yes, you should be able to treat what you build on top (upstream)
> and where you publish the result (we are still looking for a better
> name in the other thread) as two distinct things in a triangular
> workflow.  I agree that it is an issue we need to address.
>
> We have solved a half ("push goes to a different repository") but
> not the other half ("updates a branch whose name is different from
> the upstream") in the upcoming 1.8.3 release.
>
> The latest round of design from Felipe calls it branch.$name.push,
> if I am not mistaken.
>
> I think it is somewhat an overkill, though.
It is needed.
Show 13 quoted lines
> It is normal for upstream's name not to match the topic's name
> (i.e. your 'topic' may branch off of a generic 'master', but would
> be named after a more specific purpose of the branch and is unlikely
> to be named 'master'.  In other words, branch.$name.merge that
> points at an upstream that has a name that is totally different from
> $name is not an exception.  So branch.$name.merge that you have to
> set for each branch is a necessity.
>
> However, if you were to push out 'topic' directly (as opposed to
> pushing out a result of integrating it and other topic branches to
> your 'master') to your own publishing point, it is likely you would
> push it out to the same name (i.e. 'topic' will be pushed out as
> 'topic', not as 'master').
Likely, but not certain.
Show 5 quoted lines
> And if that is your workflow, setting
> push.default to "current" (and setting remote.pushdefault to your
> publishing repository) should be a sufficient interim solution, and
> you do not need to set branch.$name.push to each and every branch
> you intend to push out, I think.
If git needs configurations to behave sanely, git is broken.

If we set: branch.autosetupmerge = always push.default = simple

By default in v2.0, and there's a UI to set remote.pushdefault, then I might be inclined to agree that branch.$name.push is overkill.

But I don't see that happening; the user still needs a sane way to make trivial workflows work without hacking the configuration.

-- 
Felipe Contreras
Kevin Bracey· May 18, 2013, 14:29 UTC · re: Junio C Hamano · lore

Re: [RFC] New kind of upstream branch: base branch

On 17/05/2013 22:51, Junio C Hamano wrote:
Show 15 quoted lines
> Kevin Bracey <kevin@bracey.fi> writes:
>
>> On 15/05/2013 23:34, Felipe Contreras wrote:
>>>    I think I'm using 'upstream' for something it was not intended to,
>>> and
>>> I think the current 'upstream' behavior should be split into
>>> 'upstream' and 'base'.
>>>
>> I found myself thinking the same thing. It's really convenient being
>> able to set your topic branch's upstream to another local branch, so
> What is that "another local branch"? ...  And if that is your workflow, setting
> push.default to "current" (and setting remote.pushdefault to your
> publishing repository) should be a sufficient interim solution, and
> you do not need to set branch.$name.push to each and every branch
> you intend to push out, I think.

I agree that using "push.default current" covers some cases - I hadn't really considered it - tended to just stick with "upstream". "current" nearly does the job, but I will sometimes be wanting different names.

What I'll often be doing is creating a topic branch based on master or origin/master. (I would hardly ever be updating master or pushing to origin/master myself, so I probably should be just doing origin/master, but I tend to create a local master just to save typing on all those "git rebase origin/master").

During work, to give others visibility, and the possibility to tinker with the topic branch during development (as we don't have full inter-site sharing of work areas), I would push the topic branch up to the central "origin" server, often with a "kbracey/" prefix, partially for namespacing, and partially to indicate it's currently "private" work and subject to rebasing. I guess I could create the topic branch as "kbracey/topic" locally, but I'd rather not have to.

So I'd like "git rebase (-i)" to move my topic branch up (origin/)master. And I'd like "git push (-f)" to send it to "origin/kbracey/topic". And by extension, I suppose "git pull --rebase" to update origin/master and rebase. (Although I'm not much of a puller - I tend to fetch then rebase manually).

The final releasing procedure for the topic branch would be to hand that branch over to an integrator, who would then merge/rebase it into master.

And it would be ideal if the initial base and push tracking information could be set up automatically on the first "git checkout -b"/"git branch" and "git push". (For one, I've always found it odd that there's an asymmetry - if you check out a topic branch from the server to work on or use it, you get a local copy with upstream set by default. But if you create a topic branch yourself then push it, the upstream isn't set by default - you need the -u flag. This seems odd to me, and I've seen others confused by this).

Kevin
Ramkumar Ramachandra· May 18, 2013, 18:14 UTC · re: Kevin Bracey · lore

Re: [RFC] New kind of upstream branch: base branch

Kevin Bracey wrote:
Show 5 quoted lines
> What I'll often be doing is creating a topic branch based on master or
> origin/master. (I would hardly ever be updating master or pushing to
> origin/master myself, so I probably should be just doing origin/master, but
> I tend to create a local master just to save typing on all those "git rebase
> origin/master").

branch.<name>.merge was designed primarily for pull and merge. I use operations like git diff origin.., git log origin.., git rebase [-i] origin. Ofcourse, rebase is a bit of a special case because it defaults to operating on branch.<name>.merge by default: this is useful to me when I want to rebase against what I just fetched (central workflows: we're slowly getting triangular workflows). Abusing branch.<name>.merge because you want a different default for rebase means we're doing something wrong. Perhaps we should get a rebase.defaultUpstream = @{u}|origin|... -- @{u} being the current default. In my opinion, branch.<name>.base is a huge overkill.

Show 7 quoted lines
> During work, to give others visibility, and the possibility to tinker with
> the topic branch during development (as we don't have full inter-site
> sharing of work areas), I would push the topic branch up to the central
> "origin" server, often with a "kbracey/" prefix, partially for namespacing,
> and partially to indicate it's currently "private" work and subject to
> rebasing.  I guess I could create the topic branch as "kbracey/topic"
> locally, but I'd rather not have to.

All we have to do for this is to allow the user to set a custom refspec using remote.<name>.push. The refspecs you get now are limited to the ones set by the different modes of push.default (see builtin/push.c to see what refspec each of them set). We discussed branch.<name>.push too on another thread, but I'm not convinced that we need it.

> (Although I'm not much of a puller - I tend to fetch then rebase manually).

pull needs to be fixed. I've partially fixed the rebasing pull thing with rebase.autostash (still in pu), but there's a lot of work to be done there.

Show 7 quoted lines
> And it would be ideal if the initial base and push tracking information
> could be set up automatically on the first "git checkout -b"/"git branch"
> and "git push". (For one, I've always found it odd that there's an asymmetry
> - if you check out a topic branch from the server to work on or use it, you
> get a local copy with upstream set by default. But if you create a topic
> branch yourself then push it, the upstream isn't set by default - you need
> the -u flag. This seems odd to me, and I've seen others confused by this).

It happens because @{u} doesn't exist before the first push. We should definitely fix git checkout -b to inherit branch.<name>.remote and infer branch.<name>.merge.

To sum it up, lots of work to be done.
Felipe Contreras· May 18, 2013, 22:42 UTC · re: Kevin Bracey · lore

Re: [RFC] New kind of upstream branch: base branch

On Sat, May 18, 2013 at 9:29 AM, Kevin Bracey <kevin@bracey.fi> wrote:
Show 56 quoted lines
> On 17/05/2013 22:51, Junio C Hamano wrote:
>>
>> Kevin Bracey <kevin@bracey.fi> writes:
>>
>>> On 15/05/2013 23:34, Felipe Contreras wrote:
>>>>
>>>>    I think I'm using 'upstream' for something it was not intended to,
>>>> and
>>>> I think the current 'upstream' behavior should be split into
>>>> 'upstream' and 'base'.
>>>>
>>> I found myself thinking the same thing. It's really convenient being
>>> able to set your topic branch's upstream to another local branch, so
>>
>> What is that "another local branch"? ...  And if that is your workflow,
>> setting
>>
>> push.default to "current" (and setting remote.pushdefault to your
>> publishing repository) should be a sufficient interim solution, and
>> you do not need to set branch.$name.push to each and every branch
>> you intend to push out, I think.
>
>
> I agree that using "push.default current" covers some cases - I hadn't
> really considered it - tended to just stick with "upstream". "current"
> nearly does the job, but I will sometimes be wanting different names.
>
> What I'll often be doing is creating a topic branch based on master or
> origin/master. (I would hardly ever be updating master or pushing to
> origin/master myself, so I probably should be just doing origin/master, but
> I tend to create a local master just to save typing on all those "git rebase
> origin/master").
>
> During work, to give others visibility, and the possibility to tinker with
> the topic branch during development (as we don't have full inter-site
> sharing of work areas), I would push the topic branch up to the central
> "origin" server, often with a "kbracey/" prefix, partially for namespacing,
> and partially to indicate it's currently "private" work and subject to
> rebasing.  I guess I could create the topic branch as "kbracey/topic"
> locally, but I'd rather not have to.
>
> So I'd like "git rebase (-i)" to move my topic branch up (origin/)master.
> And I'd like "git push (-f)" to send it to "origin/kbracey/topic". And by
> extension, I suppose "git pull --rebase" to update origin/master and rebase.
> (Although I'm not much of a puller - I tend to fetch then rebase manually).
>
> The final releasing procedure for the topic branch would be to hand that
> branch over to an integrator, who would then merge/rebase it into master.
>
> And it would be ideal if the initial base and push tracking information
> could be set up automatically on the first "git checkout -b"/"git branch"
> and "git push". (For one, I've always found it odd that there's an asymmetry
> - if you check out a topic branch from the server to work on or use it, you
> get a local copy with upstream set by default. But if you create a topic
> branch yourself then push it, the upstream isn't set by default - you need
> the -u flag. This seems odd to me, and I've seen others confused by this).
Indeed, and I agree.

I've started to set branch.autosetupmerge=always, so I always get an upstream no matter what. The only problem is that 'git fetch' now is useless without any argument, but that can be fixed with another configuration 'fetch.default=simple', so that it always fetches from origin, no matter what. Then, everything is consistent, it doesn't matter what 'branch.autosetupmerge' you have configured, and in which branch you are sitting at, 'git fetch' will always do something useful.

The missing problem is that you have to manually do 'git push origin kbracey/topic', and that can be solved with the concept of a downstream (branch.x.remotepush+branch.x.push).

If we have these two changes, everything would work perfectly, wouldn't it?
-- 
Felipe Contreras
Junio C Hamano· May 19, 2013, 06:22 UTC · re: Kevin Bracey · lore

Re: [RFC] New kind of upstream branch: base branch

Kevin Bracey <kevin@bracey.fi> writes:
Show 12 quoted lines
>>> I found myself thinking the same thing. It's really convenient being
>>> able to set your topic branch's upstream to another local branch, so
>
>> What is that "another local branch"? ...  And if that is your workflow, setting
>> push.default to "current" (and setting remote.pushdefault to your
>> publishing repository) should be a sufficient interim solution, and
>> you do not need to set branch.$name.push to each and every branch
>> you intend to push out, I think.
>
> I agree that using "push.default current" covers some cases - I hadn't
> really considered it - tended to just stick with "upstream". "current"
> nearly does the job, but I will sometimes be wanting different names.
Show 5 quoted lines
> What I'll often be doing is creating a topic branch based on master or
> origin/master. (I would hardly ever be updating master or pushing to
> origin/master myself, so I probably should be just doing
> origin/master, but I tend to create a local master just to save typing
> on all those "git rebase origin/master").

Do you mean, by "save typing", "instead of origin/master, I can type master"?

If you are using the "checkout -t -b topic origin/master", "git rebase" without any other argument should know that you meant to rebase against 'origin/master', so you do not even have to type 'master'.

Show 7 quoted lines
> During work, to give others visibility, and the possibility to tinker
> with the topic branch during development (as we don't have full
> inter-site sharing of work areas), I would push the topic branch up to
> the central "origin" server, often with a "kbracey/" prefix, partially
> for namespacing, and partially to indicate it's currently "private"
> work and subject to rebasing.  I guess I could create the topic branch
> as "kbracey/topic" locally, but I'd rather not have to.

Yup, that is sensible, and I think with Felipe's proposed change, you can spell it like this:

    [branch "topic"]
	remote = origin
	merge = refs/heads/master
        push = refs/heads/kbracey/topic

Note that the above assumes you did "checkout -t -b topic origin/master" as a typesaver for "git rebase".

> So I'd like "git rebase (-i)" to move my topic branch up
> (origin/)master. And I'd like "git push (-f)" to send it to
> "origin/kbracey/topic". 

Understood. And I think the [branch "topic"] configuration above would cover that use case.

> And by extension, I suppose "git pull --rebase" to update origin/master
> and rebase. (Although I'm not much of a puller -  I tend to fetch
> then rebase manually).

"git pull --rebase" would be "git fetch" followed by "git rebase", and again the [branch "topic"] configuration above would cover that use case, I think.

> And it would be ideal if the initial base and push tracking
> information could be set up automatically on the first "git checkout
> -b"/"git branch" and "git push".

I think checkout and branch is already covered with -t. There may even be a configuration option to implicitly add -t to them (I didn't check).

Show 6 quoted lines
> (For one, I've always found it odd
> that there's an asymmetry - if you check out a topic branch from the
> server to work on or use it, you get a local copy with upstream set by
> default. But if you create a topic branch yourself then push it, the
> upstream isn't set by default - you need the -u flag. This seems odd
> to me, and I've seen others confused by this).

Yeah, I would imagine that it would be trivial to add an option to cause "git push" to do that, and it would be useful if you push to and pull from the same place (I haven't thought about ramifications such an option would have on the triangular workflows, though).

Thanks.
Felipe Contreras· May 19, 2013, 08:12 UTC · re: Junio C Hamano · lore

Re: [RFC] New kind of upstream branch: base branch

Junio C Hamano wrote:
> Kevin Bracey <kevin@bracey.fi> writes:
Show 7 quoted lines
> > And it would be ideal if the initial base and push tracking
> > information could be set up automatically on the first "git checkout
> > -b"/"git branch" and "git push".
> 
> I think checkout and branch is already covered with -t.  There may
> even be a configuration option to implicitly add -t to them (I
> didn't check).
branch.autosetupmerge=always
Show 11 quoted lines
> > (For one, I've always found it odd
> > that there's an asymmetry - if you check out a topic branch from the
> > server to work on or use it, you get a local copy with upstream set by
> > default. But if you create a topic branch yourself then push it, the
> > upstream isn't set by default - you need the -u flag. This seems odd
> > to me, and I've seen others confused by this).
> 
> Yeah, I would imagine that it would be trivial to add an option to
> cause "git push" to do that, and it would be useful if you push to
> and pull from the same place (I haven't thought about ramifications
> such an option would have on the triangular workflows, though).
It would work wonderfully. Now:
== remote ==

% git checkout -b master origin/master # work % git push

== local ==

% git checkout -b topic master # work % git push # ERR % git push -u origin/master # work % git push # ERR

That doesn't work. We could set branch.autosetupmerge=always as the default, but it still wouldn't work, because push.default=simple (or at least it will be), and the names don't match.

But with my patches, and branch.autosetupmerge=always (hopefully for 2.0):
== local ==

% git checkout -b topic master # work % git push # ERR % git push --set-downstream origin/master # work % git push

Cheers.
-- 
Felipe Contreras
Felipe Contreras· May 17, 2013, 20:01 UTC · re: Kevin Bracey · lore

Re: [RFC] New kind of upstream branch: base branch

On Fri, May 17, 2013 at 2:20 PM, Kevin Bracey <kevin@bracey.fi> wrote:
Show 11 quoted lines
> On 15/05/2013 23:34, Felipe Contreras wrote:
>>
>>   I think I'm using 'upstream' for something it was not intended to, and
>> I think the current 'upstream' behavior should be split into
>> 'upstream' and 'base'.
>>
> I found myself thinking the same thing. It's really convenient being able to
> set your topic branch's upstream to another local branch, so git rebase
> works without parameters. But then I can't use upstream to point to a remote
> version of that topic branch. I want my topic branch to know both that it's
> based on master (or origin/master), and that it's upstream is origin/topic.

If you are in your topic branch, what do you expect 'git pull' to do? And what do you expect 'git push' to do?

-- 
Felipe Contreras

← back to recent threads