简体   繁体   中英

How to merge two patches(git log) of different repository

I have a use case where I wanted to merge some sub directories of two repositories in a new repo.

For this, I have created patch for both the repositories for the directories I need using

git log --pretty=email --patch-with-stat --reverse --full-index --binary -- path/to/file_or_folder > patch1
git log --pretty=email --patch-with-stat --reverse --full-index --binary -- path/to/file_or_folder > patch2

Now, I wanted to merge both the patch in the new repository using git am, when I am doing it the commit history is coming repo by repo (which is expected). Is there a way I can get the commit history sorted by date, irrespective of where the commit came from?

If you want to produce patches to be consumed by git am , you should use git format-patch , not git log .

The commit history is never sorted by date, but always like parent / child relationship. The dates are rather unimportant for order of commits.

What you probably should do is to use format-patch to produce one am -appliably patch file per commit, then order those commits by author date and use git am in that order on the patch files, then the commits are ordered like you want them to I think.

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