简体   繁体   中英

Combine parallel branches into linear git history

have a repository with multiple roots looking like this where J is the merge commit

A---C-D-E-----H-I-J
  B-------F-G----/

I want it to look like this

A-B-C-D-E-F-G-H-I-J

B needs to go between A and C because the commit date is between A and C, so the resulting linear history needs to be combined based on the date, I do not just want the one rebased on top of the other.

The files in the 2 branches are in different subdirectories and can therefore not create conflicts.

Obviously the above is just an example. The real repo contains multiple parallel branches and many commits, so a manually rebasing part by part is out of the question.

当基于日期时,您可以使用git rev-list命令排序提交,然后选择它们:

git rev-list --date-order --reverse J ^A | xargs git cherry-pick

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM