threads / discuss / 38478

How to rebase one branch of the merge commit?

Subject: How to rebase one branch of the merge commit?

## tl;dr

3 messages between Feb 1, 2015 and Feb 9, 2015.

replies: 2people: 2as markdown or json

Hans Ginzel· Feb 1, 2015, 18:42 UTC · lore
Hello!
Suppose following git history:
A–M–C
  /
B
How to achieve this with commits metadata preserving?
A–M'–C'
  /
B'
I did

git checkout B git add something_not_in_other_commits git commit --amend

So I have B'. How to continue, please? My git version is 1.7.1 (Centos 6.5).

Regards Hans

Dennis Kaarsemaker· Feb 1, 2015, 19:28 UTC · re: Hans Ginzel · lore

Re: How to rebase one branch of the merge commit?

On zo, 2015-02-01 at 19:42 +0100, Hans Ginzel wrote:
Show 21 quoted lines
> Hello!
> 
> Suppose following git history:
> 
> A–M–C
>   /
> B
> 
> How to achieve this with commits metadata preserving?
> 
> A–M'–C'
>   /
> B'
> 
> I did
> 
> git checkout B
> git add something_not_in_other_commits
> git commit --amend
> 
> So I have B'. How to continue, please? My git version is 1.7.1 (Centos 6.5).
Assuming you have a branch pointing to C and no uncommitted changes:
1) git checkout branch-that-points-to-c
2) git rev-parse branch-that-point-to-c
3) git reset --hard A
4) git merge B'
5) git cherry-pick sha1-that-was-the-output-of-step-2
-- 
Dennis Kaarsemaker
www.kaarsemaker.net
Hans Ginzel· Feb 9, 2015, 11:38 UTC · re: Dennis Kaarsemaker · lore

Re: How to rebase one branch of the merge commit?

On Sun, Feb 01, 2015 at 08:28:28PM +0100, Dennis Kaarsemaker wrote:
Show 24 quoted lines
>On zo, 2015-02-01 at 19:42 +0100, Hans Ginzel wrote:
>> Hello!
>>
>> Suppose following git history:
>>
>> A–M–C
>>   /
>> B
>>
>> How to achieve this with commits metadata preserving?
>>
>> A–M'–C'
>>   /
>> B'
>>
>> I did
>>
>> git checkout B
>> git add something_not_in_other_commits
>> git commit --amend
>>
>> So I have B'. How to continue, please? My git version is 1.7.1 (Centos 6.5).
>
>Assuming you have a branch pointing to C and no uncommitted changes:
>1) git checkout branch-that-points-to-c
>2) git rev-parse branch-that-point-to-c
>3) git reset --hard A
>4) git merge B'
This creates a new merge comit (M').
>5) git cherry-pick sha1-that-was-the-output-of-step-2
This does nothing: "Finished one cherry-pick. nothing to commit (working directory clean)"

Thank you, but how to preserve date, message author of the original merge commit (M) to the new one (M'), please?

Regards, HG

← back to recent threads