We forgot a Pull Request when Splitting a Repo

We’re working on a little skunk works project at the office and it involved splitting a Github repository in two. After a successful split, I noticed we’d missed a PR that now impacts both repositories.

My head went to git format-patch <sha>, but I didn’t recall an option to target a file spec and at first glance it generates a patch for every commit after that SHA.

git show on the other hand definitely advertises an option to filtergit show <sha> -- path/that/moved

Format that as --pretty=email and you can direct the output to a patch for

git show --pretty=email <sha> -- path/that/moved> pr-for-other-repo.patch

Now we can pull that into our other repo with git am -3 pr-for-other-repo.patch.

Turns out that -- path/that/moved semantic does work with git format-patch. So in the end, we could have just used

git format-patch -1 -- path/that/moved
git am -3 partial-pr.patch

Leave a Reply

Your email address will not be published. Required fields are marked *