threads / discuss / 27339

fast forward a branch from another

Subject: fast forward a branch from another

## tl;dr

7 messages between May 12, 2011 and May 12, 2011.

replies: 6people: 5as markdown or json

Eric Frederich· May 12, 2011, 14:40 UTC · lore

Often times I get into a situation where I have a "development" branch that gets ahead of say a "stable" branch. When I am ready to call the development branch stable this is what I do.

$ git checkout stable $ git merge development $ git checkout development

The problem here is that the act of going backwards (via checking out stable) really messes up my IDE and or Text editors. Is there any way to do this without switching branches, which modifies my working directory, which messes up my IDE?

Thanks, ~Eric

Michael J Gruber· May 12, 2011, 15:31 UTC · re: Eric Frederich · lore

Re: fast forward a branch from another

Eric Frederich venit, vidit, dixit 12.05.2011 16:40:
Show 12 quoted lines
> Often times I get into a situation where I have a "development" branch
> that gets ahead of say a "stable" branch.
> When I am ready to call the development branch stable this is what I do.
> 
> $ git checkout stable
> $ git merge development
> $ git checkout development
> 
> The problem here is that the act of going backwards (via checking out
> stable) really messes up my IDE and or Text editors.
> Is there any way to do this without switching branches, which modifies
> my working directory, which messes up my IDE?

I assume this is a ff-situation, i.e. stable is fully contained in developement? then you can reset branch stable like this:

test 0 -eq $(git rev-list --count ^development stable) && git branch -f stable development

(I thought you could git rev-list --quiet but I'm too dumb :|)
Michael
Michael J Gruber· May 12, 2011, 15:34 UTC · re: Michael J Gruber · lore

Re: fast forward a branch from another

Michael J Gruber venit, vidit, dixit 12.05.2011 17:31:
Show 21 quoted lines
> Eric Frederich venit, vidit, dixit 12.05.2011 16:40:
>> Often times I get into a situation where I have a "development" branch
>> that gets ahead of say a "stable" branch.
>> When I am ready to call the development branch stable this is what I do.
>>
>> $ git checkout stable
>> $ git merge development
>> $ git checkout development
>>
>> The problem here is that the act of going backwards (via checking out
>> stable) really messes up my IDE and or Text editors.
>> Is there any way to do this without switching branches, which modifies
>> my working directory, which messes up my IDE?
> 
> I assume this is a ff-situation, i.e. stable is fully contained in
> developement? then you can reset branch stable like this:
> 
> test 0 -eq $(git rev-list  --count ^development stable) && git branch -f
> stable development
> 
> (I thought you could git rev-list --quiet but I'm too dumb :|)

In fact, am I even too dumb to set my from address today. Sorry! Have to give "virtual identity" another try...

Michael
Junio C Hamano· May 12, 2011, 16:06 UTC · re: Eric Frederich · lore

Re: fast forward a branch from another

Eric Frederich <eric.frederich@gmail.com> writes:
Show 7 quoted lines
> Often times I get into a situation where I have a "development" branch
> that gets ahead of say a "stable" branch.
> When I am ready to call the development branch stable this is what I do.
>
> $ git checkout stable
> $ git merge development
> $ git checkout development

Instead of switching to "stable", while still on the development, you could do

	$ git push . HEAD:stable

which would succeed only when you are purely ahead of stable (otherwise it will fail as you are not forcing).

Phil Hord· May 12, 2011, 16:26 UTC · re: Junio C Hamano · lore

Re: fast forward a branch from another

On 05/12/2011 12:06 PM, Junio C Hamano wrote:
Show 9 quoted lines
> [...]
> Instead of switching to "stable", while still on the development, you
> could do
>
> 	$ git push . HEAD:stable
>
> which would succeed only when you are purely ahead of stable (otherwise it
> will fail as you are not forcing).
>

Wow! Another gem. I didn't realize you could use 'dot' to refer to the same repo you're in.

I don't see this feature listed in the git push [REMOTES] section. Is it documented somewhere else?

Phil
Junio C Hamano· May 12, 2011, 16:49 UTC · re: Phil Hord · lore

Re: fast forward a branch from another

Phil Hord <hordp@cisco.com> writes:
> I don't see this feature listed in the git push [REMOTES] section.  Is
> it documented somewhere else?

Both "git help push" and "git help pull" will tell you in the "Git URLs" section that a local file path is a way to name a repository. Therefore, you can say "git ls-remote $(pwd)" to list the the refs from the current repository. If you are in git.git directory, "git ls-remote ../git.git" does the same thing, so does "git ls-remote .".

These are merely specializations of more general "git push $path $refspec" and nothing noteworthy.

Phil Hord· May 12, 2011, 16:58 UTC · re: Junio C Hamano · lore

Re: fast forward a branch from another

On 05/12/2011 12:49 PM, Junio C Hamano wrote:
Show 12 quoted lines
> Phil Hord <hordp@cisco.com> writes:
>
>> I don't see this feature listed in the git push [REMOTES] section.  Is
>> it documented somewhere else?
> Both "git help push" and "git help pull" will tell you in the "Git URLs"
> section that a local file path is a way to name a repository.  Therefore,
> you can say "git ls-remote $(pwd)" to list the the refs from the current
> repository. If you are in git.git directory, "git ls-remote ../git.git"
> does the same thing, so does "git ls-remote .".
>
> These are merely specializations of more general "git push $path $refspec"
> and nothing noteworthy.

Thanks for pointing out the obvious to me. I guess I was thinking of it as a parallel to '-', as in 'git checkout -', and simultaneously distracted by the surprise realization that one can push from/to the self-same repository.

Phil

← back to recent threads