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 usegit format-patch, notgit 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-patchto produce oneam-appliably patch file per commit, then order those commits by author date and usegit amin that order on the patch files, then the commits are ordered like you want them to I think.