Home/Guides/Manage Multiple Git Repos

Guide

How to Manage Multiple Git Repos from One Terminal Workflow

If you work at a company with microservices, contribute to open source, and have personal projects, you might easily have 50-200 git repos on your machine. Here is how to keep them organized and accessible without losing your mind.

The Challenge

Managing multiple repos is not a single problem. It is actually several problems tangled together:

  • --Discovery: Where is that repo? Did I clone it already? What is it called?
  • --Navigation: Getting into the right directory quickly.
  • --Prioritization: Which of these 150 repos do I actually need right now?
  • --Workspace setup: Opening the editor, starting dev servers, arranging terminal panes for the specific project.

Most tools solve one of these. A good workflow solves all of them together.

Directory Structure Best Practices

Before thinking about tooling, get your directory structure right. The most scalable pattern mirrors how GitHub organizes repositories: ~/dev/owner/repo.

~/dev/
mycompany/
api-gateway/
frontend/
auth-service/
infrastructure/
personal/
dotfiles/
blog/
facebook/
react/
golang/
go/

This pattern has several advantages:

  • +It matches your mental model of ownership. You know immediately which org a repo belongs to.
  • +No naming collisions. Two different orgs can have a repo called api without conflict.
  • +Fuzzy search works well because "mycompany/api" is unambiguous.
  • +Tools like son and ghq adopt this layout by default.

Discovery and Sorting

Once your repos are organized, you need a way to list and search them. The simplest approach is a find command piped into fzf:

$ find ~/dev -maxdepth 3 -name ".git" -type d | sed 's|/\.git$||' | sort
/Users/you/dev/facebook/react
/Users/you/dev/golang/go
/Users/you/dev/mycompany/api-gateway
/Users/you/dev/mycompany/auth-service
/Users/you/dev/mycompany/frontend
/Users/you/dev/mycompany/infrastructure
/Users/you/dev/personal/blog
/Users/you/dev/personal/dotfiles

But alphabetical sorting is almost useless. You do not care about repos alphabetically -- you care about which ones you are actively working on.

Ranking by Activity (Frecency)

Frecency is a portmanteau of frequency and recency. The idea comes from browser history ranking: a page you visited 50 times last month but not since should rank lower than one you visited 5 times today.

You can approximate this with git. The most recent commit timestamp in a repo is a decent proxy for how recently you worked on it:

# Sort repos by most recent commit
for repo in ~/dev/*/*; do
ts=$(git -C "$repo" log -1 --format=%ct 2>/dev/null || echo 0)
echo "$ts $repo"
done | sort -rn | head -10
1712505120 /Users/you/dev/mycompany/api-gateway
1712501880 /Users/you/dev/personal/blog
1712498700 /Users/you/dev/mycompany/frontend

This gives you recency but not frequency. True frecency requires tracking both access count and access time over a window. Tools like zoxide do this for directories. son does it specifically for project selection, combining how often you open a project with how recently you opened it.

# son output: projects sorted by frecency
$ son --list
mycompany/api-gateway 07 Apr 15:32 f:42
mycompany/frontend 06 Apr 22:45 f:27
personal/blog 05 Apr 11:30 f:15
mycompany/auth-service 01 Apr 09:00 f:3
facebook/react 28 Mar 14:00 f:1

The f: score tells you at a glance which projects dominate your workflow. Projects you have not touched in weeks naturally sink to the bottom.

Favorites and Pinning

Frecency is great for daily work, but sometimes you have a project that you access infrequently yet want at the top of your list -- like an infrastructure repo you need during on-call. You can handle this with favorites or pinning.

# Pin a project in son
$ son --pin mycompany/infrastructure
# Pinned projects always appear first
$ son
* mycompany/infrastructure (pinned)
▶ mycompany/api-gateway f:42
mycompany/frontend f:27

Workspace Launch

Finding a repo is only half the battle. The other half is setting up your workspace for that specific project. Different projects need different things:

  • --A Go API might need an editor pane, a server pane running go run ., and a test pane.
  • --A React frontend might need npm run dev in one pane and a shell for git in another.
  • --A monorepo might need panes for multiple services simultaneously.

You can define per-project workspace configs in a .son.toml file:

# ~/dev/mycompany/api-gateway/.son.toml
layout = "split"
editor = "nvim"
 
[[panes]]
cmd = "go run ."
name = "server"
 
[[panes]]
cmd = "go test ./... -v"
name = "tests"

Now when you select api-gateway, son opens a split layout with your editor on one side and your server and test runners on the other. See the tmux split panes guide for more layout options.

Putting It All Together with son

Here is the complete workflow when everything is in place:

# 1. You press Ctrl+P (bound to son)
# 2. Fuzzy picker appears with frecency-sorted projects
? Select project:
▶ mycompany/api-gateway 07 Apr 15:32 f:42
mycompany/frontend 06 Apr 22:45 f:27
personal/blog 05 Apr 11:30 f:15
 
# 3. You type "front" + Enter
 
# 4. Workspace opens:
Opening mycompany/frontend in tmux with split layout...
Pane 1: nvim .
Pane 2: npm run dev
Workspace ready in 0.4s

From thought ("I need to check the frontend") to a fully configured workspace in under a second. No directory navigation, no remembering paths, no manual pane setup. This is the difference between managing repos and having repos managed for you.

Manage repos, not paths.

Install son and let frecency sorting surface the projects that matter.

$ brew install abdussamet032/tap/son