threads / discuss / 24527

Merge commit before branch tip

Subject: Merge commit before branch tip

## tl;dr

4 messages between Jul 26, 2010 and Jul 26, 2010.

replies: 3people: 4as markdown or json

Bradley Wagner· Jul 26, 2010, 15:38 UTC · lore

I realize this is not a best practice but is it possible to merge a branch but at a point before the branch tip?

This came up recently for us. There are 9 new commits in our stable branch that need to be merged back into "master". However, there is 1 commit (the branch tip) that we're not all that happy with and don't want to merge into the "master".

Ideally, I'd like them to show up as a merge rather than a cherry-pick basically as if I'd done the merge before that latest commit was made.

Jonathan Nieder· Jul 26, 2010, 16:06 UTC · re: Bradley Wagner · lore

Re: Merge commit before branch tip

Hi Bradley,
Bradley Wagner wrote:
> I realize this is not a best practice but is it possible to merge a
> branch but at a point before the branch tip?
I do not even think it is not a best practice.  You can do
  $ git fetch --all
  $ git merge origin/master~1
and git will happily create a merge with message
  Merge remote branch 'origin/master' (early part)

(See the "SPECIFYING REVISIONS" section of git-rev-parse(1) for more examples.)

Hope that helps, Jonathan

Matthieu Moy· Jul 26, 2010, 16:15 UTC · re: Jonathan Nieder · lore

Re: Merge commit before branch tip

Jonathan Nieder <jrnieder@gmail.com> writes:
Show 11 quoted lines
> Hi Bradley,
>
> Bradley Wagner wrote:
>
>> I realize this is not a best practice but is it possible to merge a
>> branch but at a point before the branch tip?
>
> I do not even think it is not a best practice.  You can do
>
>   $ git fetch --all
>   $ git merge origin/master~1
... or whatever commit identifier indeed:
   $ git merge 64fdc08da

is fine too, but you have to find out the 64fdc08da part (using git log for example).

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Eugene Sajine· Jul 26, 2010, 16:08 UTC · re: Bradley Wagner · lore

Re: Merge commit before branch tip

On Mon, Jul 26, 2010 at 11:38 AM, Bradley Wagner <bradley.wagner@hannonhill.com> wrote:

Show 10 quoted lines
> I realize this is not a best practice but is it possible to merge a
> branch but at a point before the branch tip?
>
> This came up recently for us. There are 9 new commits in our stable
> branch that need to be merged back into "master". However, there is 1
> commit (the branch tip) that we're not all that happy with and don't
> want to merge into the "master".
>
> Ideally, I'd like them to show up as a merge rather than a cherry-pick
> basically as if I'd done the merge before that latest commit was made.
Isn't the following giving you what you need?

$ git co master $ git merge stable~1

?

Thanks, Eugene

← back to recent threads