Re: rewrite history

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jun 16, 2011 at 11:17:58PM +0400, Ilya Basin wrote:

> Hi list. There were 2 branches. One's HEAD was modified to match a
> specific commit at another branch. Now, how to merge them according to
> this scheme?
> 
> A---B---X---E---F
>                      =>  C---D---X---E---F
> C---D---X'
> 
> X and X' have no difference. I tried to write a script to cherry-pick
> E and F, but some of commits are merges and cherry-pick fails.

I think you just want to rebase using the "-p" option to preserve
merges. Something like:

  $ git checkout -b rebased-branch F
  $ git rebase -p --onto D B

that will pick X, E, and F, and replay them on top of D, resulting in
the graph you showed above. You could also do:

  $ git rebase -p --onto X' X

if you wanted to keep X' instead of X.

The new history will be stored on "rebased-branch". You can make sure it
looks good to you, and then:

  $ git branch -f my_original_branch rebased-branch

to move the state over to your original branch. You could also just do
the rebase directly on the original A-B-X-E-F branch.

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]