qr code

BIT-101

Bill Gates touched my MacBook Pro

Migrating away from Github


[ misc ]

I am no longer relying on github for code hosting, version control, pages, anything else. I’ve fully moved over to Codeberg.

I’m not going to go into the reasons why I moved. Not here at least. If you are interested, I did a write up in my last remaining repository at github: https://github.com/bit101/farewell.

TLDR, it’s the whole push on AI there. Multiple angles, and I’m just not in alignment with where they are headed. Codeberg seems nice.

This post is more to let people know where my stuff is, and to give a bit of a story about how I made the move.

The Moving Process

When I decided to move, I had something like 123 repos on github. So, no, it was not a decision I made lightly. It took me weeks to move everything over one by one. Codeberg is great though. they have a migration function that lets you pull in your code from a bunch of different places.

migration ui on codeberg

You choose github (or whatever service you are coming from) and fill in the details.

github migration ui on codeberg

You’ll need to generate an access token on github and use it here. Tip: make sure you specify read access on just about everything when making the token so that Codeberg will be able to grab what it needs.

BTW, don’t forget to set up your ssh key on Codeberg. I’m going to assume you know how to do that. No different than github or anywhere else. Just figured I’d say it so nobody accuses me of skipping such an important step.

Another tip: get the http address of the github repo, not the ssh address. If you grab the wrong one, it will tell you though. I did it a bunch of times.

And you can just migrate the data (all the commits) or stuff like pull requests, releases, labels, issues, etc. If all goes well, which it generally does, your repo is now on Codeberg.

Then you can go into github and archive or delete it.

Updating your local clone

Now, assuming you had the repo cloned on a local machine, you’ll need to update that so it pushes and pulls to Codeberg now.

Go into the root folder of the repo and type:

git remote set-url origin <codeberg repo address>

You get that url from Codeberg, the same as if you were going to clone it. Something like ssh://git@codeberg.org/bit101/mymigratedcode.git. Here, you’ll almost certainly want the ssh address, unless it’s just read only.

Now you should be able to type git remote show origin and see that the url is updated. And of course pull, push, etc.

Stuff that didn’t make it

There were a lot of repos that were just old code that I know I’ll never touch again, projects I started that I never continued, libraries that probably won’t work with any modern code, early versions of projects that were more fully fleshed out in a later attempt. Most of that just got deleted. There were also a bunch of JavaScript libraries that probably had some interesting things in them, even though I’m not actively using them. I combined all of them into one repo and migrated that. In the end I wound up with 60-something repos. So things got cut almost in half. No regrets at all on any of the stuff that went away.

Go Code

You may not run into this, but a lot of my work over the past eight years has been in Go, which has it’s own dependency managment system that’s based on where the code lives - generally a git repo. So, for example, if I wanted to pull in my bitlib library into a project, I’d type go get github.com/bit101/bitlib. Within that library is a go.mod file that will look like this:

module github.com/bit101/bitlib

go 1.22.1

And there will be another go.sum file that is generated when you actually meet the dependencies by pulling in a specific version of a library.

github.com/bit101/bitlib v0.4.7 h1:+H/UNQmEMPkNk2CIih0hVWnL1GP4lEH9BnZHupZ+Pns=
github.com/bit101/bitlib v0.4.7/go.mod h1:d0L7f0E8a21VD7cDuVuIsNyD4yqqxZsvgKxh5Nx433E=

Finally, each file that imports anything from bitlib will have stuff like this:

import (
	"github.com/bit101/bitlib/geom"
	"github.com/bit101/bitlib/random"
)

So… for each library I ported over, I had to go through all the files and replace github.com/bit101/... with codeberg.org/bit101/.... Then, for each project I ported over I had to do the same. Actually, I generally just deleted the go.sum file and ran go mod tidy which pulls in all the dependencies and recreates go.sum.

After all that, I did a bit of testing to make sure it all worked. OK, to be honest, there are still a bunch of older projects I haven’t cleaned up yet, and some little used libraries that will need some updating. But I can create a new project and it works well from scratch, and it just takes a few minutes (usually) to update an old project.

Actually, in the middle of doing all of this migration I learned that it might be possible to set up a sort of “vanity url” which points at the actual git repo where your code is. So if you change repos, you just need to change where that vanity url points. I assume that would live on a domain I own, so I could do something like go get bit-101.com/bitlib and that would pull the code from wherever it actually lived. I still need to look into this, but no rush at this point. As long as Codeberg doesn’t abandon its mission any time soon.

Vim plugins

In recent years, I made a few vim/neovim plugins. I’m just going to call it “vim” though I’m referring to both. There are several plugin managers for vim. Generally these also operate on a github repo. I happen to use vim-plug where you specify the plugin with your github username and repo name like so:

Plug 'bit101/bufkill'

Most of the other plugin managers do something similar. The manager assumes github and looks for github.com/bit101/bufkill - which works fine if your code is in github. I don’t think it recognizes any other git sites by default. Luckily, you can just put a full url there as well, like so:

Plug 'https://codeberg.org/bit101/bufkill'

You might run into other situations with your languages or platforms that depend on github-specific paths. They’ll certainly be fixable.

Open Source

One thing I wasn’t fully aware of when I started moving things over was that Codeberg fully embraces free/libre/open source software, whatever you want to name it. If you’re creating a startup and have a bunch of private, proprietary code that’s copyrighted and trademarked, move on.

Codeberg is run by a non-profit association with an explicit mission of advancing the creation and development of free content and free and open-source software.

This mission is shared by Codeberg’s contributors, donors and association members. We, and our servers, work tirelessly to provide you with our free service. However, there is one thing that we expect from you in return: To contribute back to the ecosystem by attaching a suitable license to the works that you put out in public, so as to let others reuse and adapt your works.

This was, in general, not a big problem for me. In fact, I’m wholeheartedly on board with that! Most of my repos were already open. But, I wound up with about eight private repos that I didn’t want to open up. Things like my dot files, a few client projects, some game projects that I might want to do something with, the source for a few of my sites and my personal wiki. Codeberg does say that if you are contributing to free software, they’ll allow you 100MB space for private repos. All told my private repos added up to about 65MB so I was OK, but didn’t want to worry about it and constantly have to check file sizes.

By the way, Codeberg doesn’t get super heavy about this. It’s more like, “here’s how we look at things, please abide.” I didn’t see any threats about taking stuff down. In fact, they say if you really need a bit more space, get in touch and they’ll hear you out. This is about as heavy as I see them get:

If you do not contribute to free/libre software (or if it is limited to your personal homepage), and we feel like you only abuse Codeberg for storing your commercial projects or media backups, we might get unhappy about that.

Forgejo

Anyway, what I decided to do with my private repos is to create a private Forgejo install on my NAS. Codeberg itself is a fork of Forgejo, which is a fork of Gitea. I got this installed and moved my eight private repos over there. This is pretty neat to be honest. In fact, this very site is a Hugo static site, that is being stored in that very Forgejo install.

I will admit that I’m a bit worried about self-hosting important files like this. But my NAS has:

I’ve never had such serious data protection in my life. And I have some old Flash source files that are 27 years old and have bounced around a dozen or more computers and a Dropbox account. I think I should be OK. But yeah, I still worry.

Licenses

I took heed of Codeberg’s statement mentioned above:

…there is one thing that we expect from you in return: To contribute back to the ecosystem by attaching a suitable license to the works that you put out in public, so as to let others reuse and adapt your works.

A lot of my repos had licenses on them, but… it was probably less than half. With no license, they’re not really open source or free software. So they all have licenses now. I went with AGPL 3.0 for all the new ones. It’s a bit on the strict side. I used to use MIT most often, but never felt great about it. MIT’s license is basically, do whatever you want, just don’t come crying to me. After seeing so much abuse in recent years where billion dollar companies are using all this free and open source software and not supporting the authors at all, it seemed right to be a more strict. I don’t even think much of my stuff is in actual use anyway. I imagine people peek in to see how some particular effect was done, learn and adapt their own code to that. Which is fine with me in general.

Oh, and for the record, all the Codeberg quotes above are from their FAQ page.

Sizes

One final thing I wanted to check on was the sizes of my repos. Since I’m not dealing with a huge billion-dollar corporation, I didn’t want to be needlessly wasting space on their servers. The vast majority of my repos were under a megabyte. Most just a few kilobyes. But there were a few that were… massive. Mostly where I had inadvertently checked in a bunch of images or even videos, or other large files. I’ve cleaned up the worst offenders. There are still a half dozen or so that are a few (less than five) megabytes. I’ll get to those next.

Gitlab

OMG, after all that, I remembered I had a gitlab account. I checked and there are 35 more repos in there!

But most of them are just junk. Ideas I started and for some reason threw them up there rather than github, but never did much with. I think I can probably trash most of them. I’m not as worried about gitlab as I was with github, but they are also very much aboard the AI train. It’s billing itself as an “AI powered devsecops platform”. There’s just nothing in that description that I care about. I just want somewhere to put my code, keep track of changes and make it available to anyone else who might benefit from it. So I might as well clean up my tracks there too.

« Previous Post

Comments? Best way to shout at me is on Mastodon

Or share this post directly on Mastodon