Merging migrated Git repos


I was moving some more repositories off GitHub this afternoon. You’d have to disappear into the mountains if you refused to use things made by anyone you didn’t 100% agree with, but the effort to change easily passes the threshold considering the ghastly things they’re proud to take money to host.

Turns out I’d already migrated some repos a few months earlier, and forgot to change the origin URL. I’d still been committing changes to GitHub and didn’t notice. Whoops!

So now I had an updated repo on GitHub, and stale repo at my target that I wanted to use. How to merge the changes on the GitHub version back into the target? Smar had the perfect answer for this use case:

$ git clone $TARGET_REPO_URL
$ git fetch $GITHUB_REPO_URL master:merging
$ git merge --allow-unrelated-histories merging
$ git commit

Some of this is going to my GitLab for now while I finish building my new FreeBSD services box. I might be setting up an OrionVM VM with jails for WebDAV/CalDAV, Git, Subversion, and Minecraft. But you didn’t read that last one yet.

Author bio and support


Ruben Schade is a technical writer and IaaS engineer in Sydney, Australia who refers to himself in the third person in bios. Wait, not BIOS… my brain should be EFI by now.

The site is powered by Hugo, FreeBSD, and OpenZFS on OrionVM, everyone’s favourite cloud infrastructure provider.

You can leave me a comment by contacting me, and I might publish your thoughts. Please read the FAQs first though.

If you found this post helpful or entertaining, you can shout me a coffee or buy some silly merch. Thanks!