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

46 lines
1.8 KiB
Markdown
Raw Permalink Normal View History

2022-06-02 21:39:20 -04:00
---
2023-02-09 20:19:30 -05:00
date: 2022-06-02 21:19:29-04:00
2022-06-02 21:39:20 -04:00
draft: false
math: false
2023-01-05 14:04:45 -05:00
medium_enabled: true
2023-02-09 20:19:30 -05:00
medium_post_id: 41533d2710fd
tags:
- Git
title: Git Pushing to Multiple Remotes
2022-06-02 21:39:20 -04:00
---
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.
```ini
[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](https://github.com/brandon-rozek/website)
as well as my [SourceHut repository](https://sr.ht/~brandonrozek/website/).
I only recently started using [SourceHut](https://sr.ht/).
It's designed by [Drew Devault](https://drewdevault.com/)
and others to feature the original usage of git, via email.
This method is still in use by the Linux kernel development team.
2023-02-09 20:19:30 -05:00
I'm excited to try it out and hopefully write some future posts on this concept.