website/content/blog/git-pushing-multiple-remotes.md

1.8 KiB

date draft math medium_enabled medium_post_id tags title
2022-06-02 21:19:29-04:00 false false true 41533d2710fd
Git
Git Pushing to Multiple Remotes

Git's greatest strength is its first-class support for decentralization. Sadly, GitHub has taken over as the sole location to store code for many people.

In order to not put all my eggs into one basket, I want to utilize multiple code hosting websites to store my public repositories. This is not only for the GitHub zombie apocolypse scenario, but local outages do in fact happen and its nice to have a backup.

Ideally this backup would not come at a cost of convinience. In fact, we can edit the remotes of our git repository so that a simple git push updates all of our remotes.

The following is an example from my website. Within your repository, use the command git config -e to open an editor with your repository's git conifguration. Then edit the origin block to be configured with multiple push-urls.

[remote "origin"]
        url = git@github.com:Brandon-Rozek/website.git 
        fetch = +refs/heads/*:refs/remotes/origin/*
        pushurl = git@github.com:Brandon-Rozek/website.git
        pushurl = git@git.sr.ht:~brandonrozek/website

After this, typing git push every pushurl you have configured. For me, it updates both my GitHub repository as well as my SourceHut repository.

I only recently started using SourceHut. It's designed by Drew Devault and others to feature the original usage of git, via email. This method is still in use by the Linux kernel development team. I'm excited to try it out and hopefully write some future posts on this concept.