This is Your Sign To Clean Up Your Github

This is your sign to clean up your github!

I invited a friend to be a contributor to a repo and he took a look around my profile generally. He was politely bemused that I have over 100 repos, most of them not really that useful.

What can I say, I like to learn, I like to practice, and I like to move on when I've gotten what I can out of something.

(I don't "abandon projects," I "fail faster," ok? It's entrepreneurial.)

List all your repos

gh repo list yourusername --limit 1000 --json name,visibility,isFork | jq -r '.[] | "\(.name) \(.visibility) \(.isFork)"'

Decide which ones to keep vs archive

Don't take too long on this step. Can't remember what it does? Archive it (or delete it, even). If you knew you were going to have an interview where an employer would have you walk through the repo, would you be excited to do so? If not, archive it. Does it spark joy? If not... archive.

Create a megarepo

In the UI or on the command line.

Get Archiving!

mkdir web-experiments
cd ../
gh repo clone yourusername/some-old-repo
cd learning-lab
git remote add temp ../some-old-repo
git fetch temp
git merge --allow-unrelated-histories temp/main -m "Merge some-old-repo"
mkdir old-repos
mv some-old-repo old-repos/
git add .
git commit -m "Move some-old-repo to subfolder"
git push
git remote remove temp```

### Script it

```repos=(repo1 repo2 repo3 repo4)
for r in "${repos[@]}"; do
  cd learning-lab
  git remote add temp ../$r
  git fetch temp
  git merge --allow-unrelated-histories temp/main -m "Merge $r"
  mkdir -p old-repos
  mv $r old-repos/
  git add .
  git commit -m "Move $r"
  git remote remove temp
done

for r in "${repos[@]}"; do
  gh repo archive yourusername/$r
done