<?xml version="1.0" encoding="utf-8" standalone="yes"?><?xml-stylesheet href="/rss.xsl" type="text/xsl" ?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Git | Bacardi55&#39;s Web Cave</title>
    <link>https://bacardi55.io/tags/git/</link>
    <description>Recent content in Git on Bacardi55&#39;s Web Cave</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <managingEditor>bac@rdi55.pl (bacardi55)</managingEditor>
    <webMaster>bac@rdi55.pl (bacardi55)</webMaster>
    <copyright>2010-2025 bacardi55</copyright>
    <lastBuildDate>Fri, 26 Jul 2024 00:00:00 +0200</lastBuildDate>
    <atom:link href="https://bacardi55.io/tags/git/index.xml" rel="self" type="application/rss+xml" />
    <item>
      
      <title>Re-thinking my git hosting with sourcehut and forgejo</title><link>https://bacardi55.io/2024/07/26/re-thinking-my-git-hosting-with-sourcehut-and-forgejo/</link><pubDate>Fri, 26 Jul 2024 00:00:00 +0200</pubDate><author>bac@rdi55.pl (bacardi55)</author><guid>https://bacardi55.io/2024/07/26/re-thinking-my-git-hosting-with-sourcehut-and-forgejo/</guid><description>&lt;h2 id=&#34;introduction&#34;&gt;Introduction&lt;/h2&gt;&#xA;&lt;p&gt;&lt;strong&gt;TLDR;&lt;/strong&gt; I&amp;rsquo;ve moved my project to &lt;a href=&#34;https://sourcehut.org&#34;&gt;sourcehut&lt;/a&gt;, see &lt;a href=&#34;https://sr.ht/~bacardi55&#34;&gt;my projects&lt;/a&gt; there, while maintaining a private and local &lt;a href=&#34;https://forgejo.org&#34;&gt;forgejo&lt;/a&gt; instance.&lt;/p&gt;&#xA;&lt;p&gt;Last year, I realized that my projects were in too many repos. I&amp;rsquo;ve been using github like many others for a long time, but I also had an account on gitlab, codeberg and sourcehut. I also have a few account on selfhosted repos from specific projects, but I&amp;rsquo;m not going to talk about these cases in this post.&lt;/p&gt;&#xA;&lt;p&gt;After years of pushing codes everywhere… I had projects everywhere: github, gitlab, codeberg and sourcehut… So it was time to do something about it!&lt;/p&gt;&#xA;&lt;h2 id=&#34;context&#34;&gt;Context&lt;/h2&gt;&#xA;&lt;p&gt;Early last year, after testing sourcehut for a while, I was convinced it was the best forge &lt;strong&gt;for me&lt;/strong&gt;. The &amp;ldquo;for me&amp;rdquo; is important, because I don&amp;rsquo;t think sourcehut is for everyone… And while it isn&amp;rsquo;t perfect (in particular its UI and how to navigate between each sourcehut features), I find it the best for my needs.&lt;/p&gt;&#xA;&lt;p&gt;But at that point my repositories were a mess: projects were either on 1, all or a subset of the mentioned forges… Clear primary forge was not indicated and no way to have a good vision of all my projects…&#xA;Let&amp;rsquo;s just say that this was not ideal and even myself wasn&amp;rsquo;t sure what were where…&lt;/p&gt;&#xA;&lt;p&gt;And then sourcehut (and codeberg to a lesser extent) suffered &lt;a href=&#34;https://sourcehut.org/blog/2024-01-16-sourcehut-outage/&#34;&gt;massive DDoS attacked&lt;/a&gt; that put them down, specially Sourcehut that was out for multiple days. That event made me realized 3 things:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I wanted a go to forge as my main &amp;ldquo;public&amp;rdquo; forge&lt;/li&gt;&#xA;&lt;li&gt;I needed a selfhosted forge to still push code during downtime of my main public forge&lt;/li&gt;&#xA;&lt;li&gt;I had to do some cleaning and clearly archive / close unused / unmaintained repos&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;A good question would be: &amp;ldquo;then why not just using one selfhosted platform only?&amp;rdquo;. But hosting my own forge publicly comes with big drawbacks:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I&amp;rsquo;ve found that bot crawlers are taking a lot of resources to crawl all public repositories.&lt;/li&gt;&#xA;&lt;li&gt;Git access via ssh (to push) would need opening port 22 to the internet and do a lot configuration in my network.&lt;/li&gt;&#xA;&lt;li&gt;A &amp;ldquo;known&amp;rdquo; public forge is usually easier to contribute.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;So I rolled up my sleeves and decided to go through the migration to what I hope is their final destinations…&lt;/p&gt;&#xA;&lt;h2 id=&#34;the-plan&#34;&gt;The plan&lt;/h2&gt;&#xA;&lt;h3 id=&#34;objectives-and-constraints&#34;&gt;Objectives and Constraints&lt;/h3&gt;&#xA;&lt;p&gt;The goals were simple:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Have one main public forges for all open source projects: For that, I choose sourcehut&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Have a selfhosted forges in case I want to push code and sourcehut is down. Also to host projects that I don&amp;rsquo;t want on sourcehut, even as a private project.&lt;/li&gt;&#xA;&lt;li&gt;Clear indications for users / contributors on where to find the up to date version of a code.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3 id=&#34;exception&#34;&gt;Exception&lt;/h3&gt;&#xA;&lt;p&gt;I made 2 small exceptions for the 2 gemini RFC proposals. Collaboration are already taken place there and I&amp;rsquo;m sure some people had to create account to participate there and may not want to move. Also, as it is an RFC, having a small UI to edit the text and create a merge request may be easy than the git email workflow. That is why the &lt;a href=&#34;https://codeberg.org/bacardi55/gemini-tinylog-rfc&#34;&gt;Gemini Tinylog RFC&lt;/a&gt; and the &lt;a href=&#34;https://codeberg.org/bacardi55/gemini-mentions-rfc&#34;&gt;Gemini Mention RFC&lt;/a&gt; primary repositories are still on codeberg.&lt;/p&gt;&#xA;&lt;p&gt;All my other repositories follow the new plan.&lt;/p&gt;&#xA;&lt;h2 id=&#34;new-state&#34;&gt;New state&lt;/h2&gt;&#xA;&lt;h3 id=&#34;local-forgejo-instance&#34;&gt;Local Forgejo Instance&lt;/h3&gt;&#xA;&lt;p&gt;As said, I decided to use Forgejo for my local private instance. I won&amp;rsquo;t cover the installation details, their documentation covers it well already.&lt;/p&gt;&#xA;&lt;p&gt;This instance is only used by me for:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Private repository that I don&amp;rsquo;t want on sourcehut (even in private) or any other public forges&lt;/li&gt;&#xA;&lt;li&gt;Very old and unused code that I want to keep&lt;/li&gt;&#xA;&lt;li&gt;Hosting the code of all projects I host elsewhere. I don&amp;rsquo;t use mirroring here, I actually have to push to multiple remotes (see this post where I &lt;a href=&#34;https://bacardi55.io/2024/02/21/git-tips-push-to-multiple-git-repo-in-one-command/&#34;&gt;explained how I do it&lt;/a&gt; via &lt;code&gt;git remote --set-url&lt;/code&gt;)&lt;/li&gt;&#xA;&lt;li&gt;Sometimes used to push things before I push them publicly to sourcehut (or other)&lt;/li&gt;&#xA;&lt;li&gt;Serve also as a backup of all my code: the instance itself is a backup of project on 3rd party forges (or the other way around), but also, the container hosting forgejo is part of my backup process with proxmox and borgbackup, so all covered :).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;As you understood, every single project managed by git is hosted on this private instance. It isn&amp;rsquo;t used for anything else (no CI/CD, no public pages, no collaboration).&lt;/p&gt;&#xA;&lt;h3 id=&#34;sourcehut&#34;&gt;Sourcehut&lt;/h3&gt;&#xA;&lt;p&gt;The new public home for all my projects. Took a bit of time to get used to its UI and workflow, but I really enjoy using it. I won&amp;rsquo;t detail right now how sourcehut works differently than other &amp;ldquo;traditional&amp;rdquo; forge (=aka github workflow), but I&amp;rsquo;ll talk about why sourcehut in a later post.&lt;/p&gt;&#xA;&lt;p&gt;One important thing to have in mind: on sourcehut, you can create projects to group multiple repositories (themselves attached to mailing lists and todolists) together. It means that you can have one project with mutltiple repositories but still a common todolist for example. It also allows to have a git repository in multiple projects, which can be useful too (see below as I&amp;rsquo;m using it).&lt;/p&gt;&#xA;&lt;p&gt;It takes some time to grasp the full concepts of sourcehut, but the flexibility is way higher than with other forges.&#xA;I&amp;rsquo;m using sourcehut projects for grouping codebases together or for &amp;ldquo;larger&amp;rdquo; projects on which I&amp;rsquo;d be happy to see collaboration.&#xA;Smaller code are not in projects and just standalone repos (with mailing list and todolist still possible).&lt;/p&gt;&#xA;&lt;p&gt;Sourcehut allows projects and codebases to be visible, unlisted or private. A project can have repos with different visibility.&lt;/p&gt;&#xA;&lt;p&gt;For example, I created a &lt;a href=&#34;https://sr.ht/~bacardi55/writings/&#34;&gt;writting project&lt;/a&gt; that contains 4 repositories: one for &lt;a href=&#34;https://git.sr.ht/~bacardi55/website&#34;&gt;this blog&lt;/a&gt;, one for my &lt;a href=&#34;https://git.sr.ht/~bacardi55/capsule&#34;&gt;gemini capsule&lt;/a&gt;, one for the &lt;a href=&#34;https://git.sr.ht/~bacardi55/writting-deploy&#34;&gt;deployment scripts&lt;/a&gt; (unlisted) and one for my &lt;a href=&#34;https://git.sr.ht/~bacardi55/MinIndie&#34;&gt;custom hugo theme&lt;/a&gt;. The hugo theme is both in this project and in a &lt;a href=&#34;https://sr.ht/~bacardi55/MinIndie/&#34;&gt;dedicated one&lt;/a&gt; in case people would like to contribute. Other example, I have a &lt;a href=&#34;https://sr.ht/~bacardi55/Gemini55/&#34;&gt;gemini55&lt;/a&gt; project containing all my gemini related repositories (&lt;a href=&#34;https://git.sr.ht/~bacardi55/gtl&#34;&gt;gtl&lt;/a&gt;, &lt;a href=&#34;https://git.sr.ht/~bacardi55/houston&#34;&gt;houston&lt;/a&gt;, &lt;a href=&#34;https://git.sr.ht/~bacardi55/ggm&#34;&gt;ggm&lt;/a&gt;, &lt;a href=&#34;https://git.sr.ht/~bacardi55/discogem&#34;&gt;discogem&lt;/a&gt; and a link to the 2 gemini RFCs). Some repositories are not tight to projects.&lt;/p&gt;&#xA;&lt;h3 id=&#34;what-about-other-forges&#34;&gt;What about other forges&lt;/h3&gt;&#xA;&lt;p&gt;Except the 2 Gemini RFC exceptions mentioned above, I&amp;rsquo;ve cleaned a lot my other forges presence by archiving all projects (and that took some time to do on all projects :D). Both my github and codeberg profiles indicate:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Profile used to contribute to Github projects. My own projects are hosted on sourcehut: &lt;a href=&#34;https://sr.ht/~bacardi55&#34;&gt;https://sr.ht/~bacardi55&lt;/a&gt; &lt;a href=&#34;https://git.sr.ht/~bacardi55&#34;&gt;https://git.sr.ht/~bacardi55&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I haven&amp;rsquo;t deleted my account on those forges though, as they might still be useful to collaborate on project hosted there.&lt;/p&gt;&#xA;&lt;h2 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h2&gt;&#xA;&lt;p&gt;The move is now over, I have been using solely sourcehut for quite some time now. This blog is now built via &lt;a href=&#34;https://builds.sr.ht/&#34;&gt;sourcehut builds&lt;/a&gt; and while sourcehut UI definitely needs improvements, it has been a great decision and I&amp;rsquo;ve enjoyed a lot using sourcehut since my move. Hopefully, this is a state that shouldn&amp;rsquo;t move for a while.&lt;/p&gt;&#xA;&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;&#xA;&lt;hr&gt;&#xA;&lt;ol&gt;&#xA;&lt;li id=&#34;fn:1&#34;&gt;&#xA;&lt;p&gt;: Some people might argue that sourcehut is not the best choice for this because it doesn&amp;rsquo;t provide the &amp;ldquo;classic&amp;rdquo; fork / pull request workflow, but I do believe anyone could learn fairly quickly the email workflow linked to sourcehut. Plus my project don&amp;rsquo;t have contributors in reality :P.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/div&gt;&#xA;</description></item>
    <item>
      
      <title>Git Tips: Push to multiple git repo in one command</title><link>https://bacardi55.io/2024/02/21/git-tips-push-to-multiple-git-repo-in-one-command/</link><pubDate>Wed, 21 Feb 2024 00:00:00 +0100</pubDate><author>bac@rdi55.pl (bacardi55)</author><guid>https://bacardi55.io/2024/02/21/git-tips-push-to-multiple-git-repo-in-one-command/</guid><description>&lt;p&gt;I&amp;rsquo;m currently in the process of cleaning my presences on various git forges, &lt;a href=&#34;https://sr.ht&#34;&gt;sourcehut&lt;/a&gt; being my main one now, but I also use(d) github, gitlab and &lt;a href=&#34;https://codeberg.org/&#34;&gt;codeberg&lt;/a&gt; too. Now that my strategy around repo management is clearer (more on that later), I do have some projects where I still need to push code on multiple forges.&lt;/p&gt;&#xA;&lt;p&gt;Main reason being that I also have a private &lt;a href=&#34;https://forgejo.org/&#34;&gt;Forgejo&lt;/a&gt; instance on my homelab only reachable from my home network. I&amp;rsquo;ll explain the reason in a later post about my git repo management, but that means that every repo will have at least 2 remote repositories to push to: sourcehut and this private forgejo instance.&lt;/p&gt;&#xA;&lt;p&gt;I also want some repo to stay on codeberg as their main repo, but at the same I want everything on sourcehut (even if private / unlisted), so that I know everything is there and can be made public / private / hidden depending on what is the &amp;ldquo;source of truth&amp;rdquo;.&lt;/p&gt;&#xA;&lt;p&gt;So, here we are with a quick post, more as a reminder, about publishing code to multiple git remote repository. Let&amp;rsquo;s take this website for example (repository called &lt;code&gt;website&lt;/code&gt; on sourcehut and &lt;code&gt;Blog&lt;/code&gt; on my personal git instance).&lt;/p&gt;&#xA;&lt;p&gt;By default, I already have 2 remotes I&amp;rsquo;ve added with &lt;code&gt;git remote add &amp;lt;nameOfRemote&amp;gt; &amp;lt;urlOfRemoteRepo&amp;gt;&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;p&gt;In the project directory:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;git remote -v&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Returns for example:&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code class=&#34;language-nil&#34; data-lang=&#34;nil&#34;&gt;local   git@gitssh.bacardi55.local:bacardi55/Blog.git (fetch)&#xA;local   git@gitssh.bacardi55.local:bacardi55/Blog.git (push)&#xA;srht    git@git.sr.ht:~bacardi55/website (fetch)&#xA;srht    git@git.sr.ht:~bacardi55/website (push)&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;To publish on both, one could do it like this:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;git push local main &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; git push srht main&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And that&amp;rsquo;s what I&amp;rsquo;ve been using at first. I even created a small &lt;code&gt;gitpushall&lt;/code&gt; alias in my &lt;code&gt;~/.zshrc&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;alias gitpushall&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;git push local main &amp;amp;&amp;amp; git push srht main&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Which works fine because I follow the same naming convention for remote repo for all my projects. But I thought it wasn&amp;rsquo;t the &amp;ldquo;right&amp;rdquo; way and looked for a more &amp;ldquo;git-y&amp;rdquo; approach. Turns out, there is one as multiple push url can be added to a remote (but only one pull).&lt;/p&gt;&#xA;&lt;p&gt;I left the remote &lt;code&gt;local&lt;/code&gt; and &lt;code&gt;srht&lt;/code&gt; as is, and added a new remote called &lt;code&gt;all&lt;/code&gt;. This allow me to still decide to push to specific remote if I decide too (eg: pushing on my local git repo to avoid a build to be started on sourcehut CI while waiting for other commits).&lt;/p&gt;&#xA;&lt;p&gt;To add a new &lt;code&gt;all&lt;/code&gt; remote:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;git remote add all git@gitssh.bacardi55.local:bacardi55/Blog.git&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It still need a default URL, so I choose my local one as the default. Then, we are going to use the &lt;code&gt;set-url&lt;/code&gt; remote command to add remote URLs to our repository.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;&lt;strong&gt;Warning&lt;/strong&gt;&lt;/strong&gt;: The first run of &lt;code&gt;git remote set-url…&lt;/code&gt; will remove the default URL and use the provided one as default. If you want the one entered in the command above to stay the first one, reuse it first!&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;git remote set-url --add --push all git@gitssh.bacardi55.local:bacardi55/Blog.git&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;git remote set-url --add --push all git@git.sr.ht:~bacardi55/website&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Running &lt;code&gt;git remote -v&lt;/code&gt; will now show the &lt;code&gt;all&lt;/code&gt; remote with the 2 push URLs:&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code class=&#34;language-nil&#34; data-lang=&#34;nil&#34;&gt;all     git@gitssh.bacardi55.local:bacardi55/Blog.git (fetch)&#xA;all     git@gitssh.bacardi55.local:bacardi55/Blog.git (push)&#xA;all     git@git.sr.ht:~bacardi55/website (push)&#xA;local   git@gitssh.bacardi55.local:bacardi55/Blog.git (fetch)&#xA;local   git@gitssh.bacardi55.local:bacardi55/Blog.git (push)&#xA;srht    git@git.sr.ht:~bacardi55/website (fetch)&#xA;srht    git@git.sr.ht:~bacardi55/website (push)&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Then, &lt;code&gt;git push&lt;/code&gt; as usual but with the &lt;code&gt;all&lt;/code&gt; remote:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;git push all &amp;lt;branchName&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Your code should be pushed in &amp;ldquo;all&amp;rdquo; remote repository now :).&lt;/p&gt;&#xA;</description></item>
  </channel>
</rss>
