<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Git on Linux Lunatix</title><link>https://www.linux-lunatix.org/categories/git/</link><description>Recent content in Git on Linux Lunatix</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><managingEditor>blog-comments@linux-lunatix.org (hans_olo)</managingEditor><webMaster>blog-comments@linux-lunatix.org (hans_olo)</webMaster><copyright>2025 hans_olo :: All written work is licensed under CC BY-SA 4.0 unless otherwise stated. Images are taken by me unless otherwise stated and need written permission to be used elsewhere.</copyright><lastBuildDate>Mon, 23 Nov 2026 16:20:00 +0100</lastBuildDate><atom:link href="https://www.linux-lunatix.org/categories/git/index.xml" rel="self" type="application/rss+xml"/><item><title>Cleaning up an old notes repository</title><link>https://www.linux-lunatix.org/blog/cleaning-up-a-notes-repository/</link><pubDate>Mon, 23 Nov 2026 16:20:00 +0100</pubDate><author>blog-comments@linux-lunatix.org (hans_olo)</author><guid>https://www.linux-lunatix.org/blog/cleaning-up-a-notes-repository/</guid><description>&lt;p>On my second laptop, &lt;code>ctl2&lt;/code>, I had a folder called &lt;code>sysadmin&lt;/code>. It held everything I had written down while I worked on my home network: notes from the weeks when I flashed OpenWrt on the access points, a lab for LDAP and Kerberos, the setup of an old reverse proxy, and how the disks on the home server are mounted. I turned the folder into a Git repository and pushed it to my Forgejo, so that it lives next to the &lt;a href="../../blog/infra-01-consolidation/">Ansible repository&lt;/a>.&lt;/p>
&lt;p>Then I read what I had pushed. There were passwords in plain text, firmware images, the local state directory of a coding assistant, and a project that I had replaced months ago. The repository is private, but &amp;ldquo;private&amp;rdquo; only means fewer people can read it. This post is how I cleaned it up, in an order that works.&lt;/p>
&lt;h2 id="what-you-ll-have-at-the-end">What you&amp;rsquo;ll have at the end&lt;/h2>
&lt;ul>
&lt;li>A repository with notes only: no credentials, no binaries.&lt;/li>
&lt;li>Secrets that are rotated, and referenced by their name in the password store.&lt;/li>
&lt;li>What is really configuration moved into Ansible, and proven there with a &lt;code>--check&lt;/code> run.&lt;/li>
&lt;li>Stale documents marked as stale.&lt;/li>
&lt;li>A new history, on the server and on every clone.&lt;/li>
&lt;/ul>
&lt;h2 id="step-0-a-leaked-password-stays-leaked">Step 0: a leaked password stays leaked&lt;/h2>
&lt;p>Rewriting the Git history stops a secret from spreading further. It doesn&amp;rsquo;t take it back from anybody who already has a copy: a clone on another laptop, a backup of the Forgejo server, a mirror. So the first step is to change every password that was ever in the repository. The cleanup only comes after that.&lt;/p>
&lt;p>For me that was the Pi-hole admin password and the root password of the OpenWrt access points. Pi-hole got a new password the same day. The access points are on my list, and until then, I count their password as public.&lt;/p>
&lt;h2 id="step-1-find-every-secret-in-the-history-too">Step 1: find every secret, in the history too&lt;/h2>
&lt;p>The current files are easy. The history is where the old versions are:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># the current files&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">git grep -niE &lt;span class="s1">&amp;#39;passw|passphrase|psk|secret|token|api[_-]?key|userPassword&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># every version of every file, in all branches&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">git log -p --all &lt;span class="p">|&lt;/span> grep -niE &lt;span class="s1">&amp;#39;passw|passphrase|psk|secret|token|api[_-]?key|userPassword&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The pattern finds more than secrets: every sentence that mentions a password. That&amp;rsquo;s fine. Read each hit. Mine came from two places:&lt;/p>
&lt;ul>
&lt;li>the network notes: the root password of the access points and the Pi-hole password.&lt;/li>
&lt;li>an LDIF file for the LDAP lab, with the &lt;code>userPassword&lt;/code> of a bind account.&lt;/li>
&lt;/ul>
&lt;p>Tools like gitleaks and trufflehog search with patterns for hundreds of token formats (links at the end). For a small repository of notes, &lt;code>grep&lt;/code> and reading did the job.&lt;/p>
&lt;h2 id="step-2-name-the-secret-don-t-write-it-down">Step 2: name the secret, don&amp;rsquo;t write it down&lt;/h2>
&lt;p>A note needs to say &lt;em>where&lt;/em> a password is, not what it is. All my passwords are in &lt;a href="https://www.passwordstore.org/">pass&lt;/a>, so the notes now say:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">Admin password (SSH root / LuCI), the same on all OpenWrt devices: pass home/openwrt-root.
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The LDIF lost its &lt;code>userPassword&lt;/code> line. The lab&amp;rsquo;s README now says that the bind account gets its password at deploy time, from pass, and never from a file in Git.&lt;/p>
&lt;p>The coding assistant&amp;rsquo;s state directory went out completely, and into &lt;code>.gitignore&lt;/code>. It&amp;rsquo;s local state of a tool and doesn&amp;rsquo;t belong in any repository, secrets or not.&lt;/p>
&lt;h2 id="step-3-binaries-out-checksums-in">Step 3: binaries out, checksums in&lt;/h2>
&lt;p>The repository had the four OpenWrt images that I had flashed. Git stores every version of a binary forever, and the images are on the OpenWrt download server anyway. But I wanted to know which exact image is on which device. So the images left, and a checksum file with the download URLs stayed:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl"># firmware/SHA256SUMS
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&amp;lt;sha256&amp;gt; openwrt-25.12.5-ath79-generic-tplink_archer-c7-v1-squashfs-factory.bin
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&amp;lt;sha256&amp;gt; openwrt-25.12.5-ath79-generic-tplink_archer-c7-v1-squashfs-sysupgrade.bin
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&amp;lt;sha256&amp;gt; openwrt-25.12.5-ipq806x-generic-netgear_r7800-squashfs-factory.img
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&amp;lt;sha256&amp;gt; openwrt-25.12.5-mvebu-cortexa9-linksys_wrt3200acm-squashfs-factory.img
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Before I deleted the images, I checked them against the official checksums. An image of unknown origin on a router is the last thing I want:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">&lt;span class="nv">base&lt;/span>&lt;span class="o">=&lt;/span>https://downloads.openwrt.org/releases/25.12.5/targets
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">curl -fsS &lt;span class="s2">&amp;#34;&lt;/span>&lt;span class="nv">$base&lt;/span>&lt;span class="s2">/ipq806x/generic/sha256sums&amp;#34;&lt;/span> &lt;span class="p">|&lt;/span> grep netgear_r7800 &amp;gt; official.txt
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">sha256sum openwrt-25.12.5-ipq806x-generic-netgear_r7800-squashfs-factory.img
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># same hashes as in official.txt?&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>All four matched. The &lt;code>.gitignore&lt;/code> keeps new images out:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">.claude/
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">network/firmware/*.bin
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">network/firmware/*.img
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">ldap/certs/
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="step-4-mark-what-is-stale">Step 4: mark what is stale&lt;/h2>
&lt;p>A document that looks current but isn&amp;rsquo;t is worse than no document. I trust it, and it&amp;rsquo;s wrong. So every document that I didn&amp;rsquo;t check against the live network got a status line at the top:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-markdown" data-lang="markdown">&lt;span class="line">&lt;span class="cl">Status as of 2026-09-28, the end of the OpenWrt sessions; not yet re-checked against the
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">live network. The detailed plan file those sessions referred to is lost: this document
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">is the only record.
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-markdown" data-lang="markdown">&lt;span class="line">&lt;span class="cl">&lt;span class="k">&amp;gt; &lt;/span>&lt;span class="ge">**Status (2026-11-23): lab, not deployed.** Phase 1 was drafted (quadlets, LDIFs, cert
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="ge">&lt;/span>&lt;span class="k">&amp;gt; &lt;/span>&lt;span class="ge">script), but nothing runs on the home server: no container, volume or timer.
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The second one also says what has to happen before the lab goes live: it becomes an app in the Ansible repository, and the container images need a fresh look. The images it used are no longer published for free.&lt;/p>
&lt;p>The original plan of the whole project went into &lt;code>archive/&lt;/code>, with a note that it is history and not the current state.&lt;/p>
&lt;h2 id="step-5-move-what-is-really-code">Step 5: move what is really code&lt;/h2>
&lt;p>One folder described how the three Drobo disk boxes on the home server are mounted: the UUIDs, the mount options, and the owner of the share directories. That&amp;rsquo;s no note. That&amp;rsquo;s configuration, and it belongs in Ansible. The Samba role got two lists:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-yaml" data-lang="yaml">&lt;span class="line">&lt;span class="cl">&lt;span class="c"># host_vars/home1.yml&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">samba_mounts&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- {&lt;span class="nt">path: /mnt/drobo/Drobo01, src: UUID=&amp;lt;uuid&amp;gt;, fstype&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">ext3,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">opts&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;defaults,nofail,x-systemd.device-timeout=10s&amp;#34;&lt;/span>&lt;span class="nt">, owner: nobody, group: nobody, mode&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;0777&amp;#34;&lt;/span>}&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="c"># ... Drobo02 and Drobo03 the same&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">samba_dirs&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- {&lt;span class="nt">path: /mnt/drobo/Drobo01/Scans, owner: nobody, group: nobody, mode&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;0775&amp;#34;&lt;/span>}&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-yaml" data-lang="yaml">&lt;span class="line">&lt;span class="cl">&lt;span class="c"># roles/samba/tasks/main.yml&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>- &lt;span class="nt">name&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">Share disks in fstab, mounted&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">ansible.posix.mount&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">path&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;{{ item.path }}&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">src&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;{{ item.src }}&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">fstype&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;{{ item.fstype }}&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">opts&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;{{ item.opts }}&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">dump&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;0&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">passno&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;2&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">state&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">mounted&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">loop&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;{{ samba_mounts }}&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>- &lt;span class="nt">name&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">Share disk roots&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">ansible.builtin.file&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">path&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;{{ item.path }}&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">state&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">directory&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">owner&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;{{ item.owner }}&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">group&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;{{ item.group }}&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">mode&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;{{ item.mode }}&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">loop&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;{{ samba_mounts + samba_dirs }}&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>nofail&lt;/code> and the short device timeout let the server boot when a Drobo is off. Without them, systemd waits 90 seconds for the disk and then drops into emergency mode.&lt;/p>
&lt;p>The test is the same as for every host I adopted (see &lt;a href="../../blog/infra-06-quadlet-app/">the Ansible post&lt;/a>):&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">ansible-playbook playbooks/site.yml -l home1 -t samba --check --diff
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>changed=0&lt;/code>: the role describes exactly what the server already has. After that, the folder with the notes could go.&lt;/p>
&lt;h2 id="step-6-delete-what-is-dead">Step 6: delete what is dead&lt;/h2>
&lt;p>The old reverse proxy setup was a Traefik with Docker Compose, from before I moved everything to rootless Podman quadlets. Its replacement has run for months. I deleted the folder. Git keeps it in the history, and in the next step the history goes too.&lt;/p>
&lt;p>The new layout:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">sysadmin/
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">├── README.md what lives here and what lives in the Ansible repository
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">├── network/ network notes, diagrams, firmware checksums
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">├── ldap/ the LDAP/Kerberos lab (not deployed)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">└── archive/ the old plan, kept as history
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="step-7-a-new-history">Step 7: a new history&lt;/h2>
&lt;p>There are two ways to remove secrets from the history:&lt;/p>
&lt;ul>
&lt;li>Rewrite it and keep the commits: &lt;a href="https://github.com/newren/git-filter-repo">git filter-repo&lt;/a> with &lt;code>--replace-text&lt;/code> or &lt;code>--invert-paths&lt;/code>. That&amp;rsquo;s the right tool when the history has value.&lt;/li>
&lt;li>Start a new history with one commit. My history had no value for me, so that&amp;rsquo;s what I did:&lt;/li>
&lt;/ul>
&lt;!--listend-->
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">git checkout --orphan fresh
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">git add -A
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">git commit -m &lt;span class="s2">&amp;#34;sysadmin: home network docs, LDAP lab, archived plan&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">git branch -D main
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">git branch -m main
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">git push --force origin main
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>--orphan&lt;/code> starts a branch without a parent. The working tree stays, so &lt;code>git add -A&lt;/code> takes the cleaned files as they are.&lt;/p>
&lt;p>If the server protects the branch against force pushes, allow it for this one push, and turn the protection on again afterwards.&lt;/p>
&lt;h2 id="step-8-the-server-and-the-other-clones-still-have-it">Step 8: the server and the other clones still have it&lt;/h2>
&lt;p>After the force push, the old commits are unreachable, but they are not gone:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>The server.&lt;/strong> Forgejo keeps unreachable objects until a garbage collection runs. An admin can start one in the site administration, under the maintenance operations. Until then, anybody who knows an old commit hash can still open it. Pull requests also keep references to old commits.&lt;/li>
&lt;li>&lt;strong>The other clones.&lt;/strong> The clone on &lt;code>ctl2&lt;/code> still had the old history. A &lt;code>git pull&lt;/code> there would have merged the old history back into the new one, and the next push would have uploaded everything again. Delete such a clone and clone again. If you must keep it, run &lt;code>git fetch &amp;amp;&amp;amp; git reset --hard origin/main&lt;/code>, and know that its reflog still has the old commits for a while.&lt;/li>
&lt;li>&lt;strong>Backups.&lt;/strong> The backup of the Forgejo server has the old objects until the backup&amp;rsquo;s retention removes them.&lt;/li>
&lt;/ul>
&lt;h2 id="check-it">Check it&lt;/h2>
&lt;p>In a fresh clone:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">git clone ssh://git@git.example.org/alice/sysadmin.git /tmp/check &lt;span class="o">&amp;amp;&amp;amp;&lt;/span> &lt;span class="nb">cd&lt;/span> /tmp/check
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">git rev-list --count --all &lt;span class="c1"># 1&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">du -sh .git &lt;span class="c1"># 148K&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Then search for the actual secrets, not for patterns. &lt;code>grep -F -f -&lt;/code> reads the search strings from stdin, so the password never shows up on the screen or in the shell history:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">pass show home/old-router-password &lt;span class="p">|&lt;/span> head -1 &lt;span class="p">|&lt;/span> grep -rqF -f - . &lt;span class="o">&amp;amp;&amp;amp;&lt;/span> &lt;span class="nb">echo&lt;/span> LEAK &lt;span class="o">||&lt;/span> &lt;span class="nb">echo&lt;/span> clean
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Do this for each password that was ever in the repository. Old passwords too: after the rotation in step 0, those are the ones the history contained.&lt;/p>
&lt;h2 id="the-rules-in-the-readme">The rules, in the README&lt;/h2>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-markdown" data-lang="markdown">&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> No credentials. Name the pass entry instead (&lt;span class="sb">`home/...`&lt;/span>).
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> No binaries. Keep checksums and download URLs.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> What becomes configuration moves to the Ansible repository.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> A document that isn&amp;#39;t checked against the live system gets a dated status line.
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The rules are short because they have to work when I&amp;rsquo;m tired, at the end of a long evening with the routers. That&amp;rsquo;s exactly when the passwords got into the notes the first time.&lt;/p>
&lt;h2 id="further-reading">Further reading&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="https://github.com/newren/git-filter-repo">git filter-repo&lt;/a>: rewrite the history and keep the commits, with &lt;code>--replace-text&lt;/code> and &lt;code>--invert-paths&lt;/code>.&lt;/li>
&lt;li>&lt;a href="https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository">Removing sensitive data from a repository (GitHub)&lt;/a>: the full procedure, with the server side and the clones.&lt;/li>
&lt;li>&lt;a href="https://github.com/gitleaks/gitleaks">gitleaks&lt;/a> and &lt;a href="https://github.com/trufflesecurity/trufflehog">trufflehog&lt;/a>: scanners for secrets in the working tree and the history.&lt;/li>
&lt;li>&lt;a href="https://git-scm.com/docs/git-checkout#Documentation/git-checkout.txt---orphanltnew-branchgt">git checkout &amp;ndash;orphan&lt;/a>: a branch without a parent.&lt;/li>
&lt;li>&lt;a href="https://git-scm.com/docs/git-gc">git gc&lt;/a>: when unreachable objects really go.&lt;/li>
&lt;li>&lt;a href="https://openwrt.org/docs/guide-quick-start/verify_firmware_checksum">OpenWrt: verify the firmware checksum&lt;/a>: the official way to check an image.&lt;/li>
&lt;li>&lt;a href="https://docs.ansible.com/ansible/latest/collections/ansible/posix/mount_module.html">ansible.posix.mount&lt;/a>: &lt;code>state: mounted&lt;/code> and the fstab options.&lt;/li>
&lt;li>&lt;a href="https://www.passwordstore.org/">pass&lt;/a>: the password store that the notes now point to.&lt;/li>
&lt;/ul></description></item></channel></rss>