Merging migrated Git repos

Software

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
$ cd $TARGET_REPO_NAME
$ 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

Me!

Ruben Schade is a technical writer and infrastructure architect in Sydney, Australia who refers to himself in the third person in bios. Hi!

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

If you found this post helpful or entertaining, you can shout me a coffee or send a comment. Thanks ☺️.