@@ -12,27 +12,32 @@ each worktree is a full working copy of a branch.
1212## Prerequisites
1313
1414- git
15+ - [ gh] ( https://cli.github.com/ ) (GitHub CLI, for repo setup recipes)
1516- [ uv] ( https://docs.astral.sh/uv/ ) (Python package manager, used to run just and copier)
1617
1718## Usage
1819
19- Set up the bare repo and main worktree yourself, then run copier to drop skeleton files :
20+ Clone an existing GitHub repo:
2021
2122``` bash
2223mkdir ~ /repos/my-project && cd ~ /repos/my-project
23- gh repo clone owner/my-project .git -- --bare
24- git worktree add main main
2524uvx copier copy gh:dpoblador/projectuner .
25+ just repo-clone owner/my-project
2626```
2727
28- For a brand-new repo with no remote:
28+ Or start a fresh repo with no remote:
2929
3030``` bash
3131mkdir ~ /repos/my-project && cd ~ /repos/my-project
32- git init --bare .git
33- git -C .git commit --allow-empty -m " Initial commit"
34- git worktree add main main
3532uvx copier copy gh:dpoblador/projectuner .
33+ just repo-init
34+ ```
35+
36+ To publish a fresh repo to GitHub:
37+
38+ ``` bash
39+ just repo-create owner/my-project # private by default
40+ just repo-create owner/my-project public # or public
3641```
3742
3843## What you get
@@ -48,34 +53,45 @@ my-project/
4853└── .copier-answers.yml
4954```
5055
51- ## Worktree workflow
56+ ## Developing with worktrees
57+
58+ All recipes are run from the project root. If you have
59+ [ just] ( https://github.com/casey/just ) installed, you can use ` just ` directly
60+ instead of ` uv run --from just-bin just ` .
5261
53- All worktree operations are just recipes, run from the project root. If you have
54- [ just] ( https://github.com/casey/just ) installed, you can use ` just <recipe> ` directly
55- instead of the ` uv run --from just-bin ` prefix.
62+ Start a feature by creating a worktree:
5663
5764``` bash
58- # Start a new feature
59- uv run --from just-bin just wt-add my-feature
65+ just wt-add my-feature # creates branch from main
66+ cd my-feature/ # full working copy, ready to go
67+ ```
6068
61- # Work in it
62- cd my-feature/
69+ Work normally (edit, commit, push) inside ` my-feature/ ` . Meanwhile ` main/ ` stays
70+ pristine, so you can diff against it anytime:
6371
64- # List all worktrees
65- uv run --from just-bin just wt-ls
72+ ``` bash
73+ git diff main...my-feature
74+ ```
6675
67- # Fetch latest and fast-forward main
68- uv run --from just-bin just wt-update
76+ You can have multiple worktrees active at once (one per branch):
6977
70- # Clean up when done (keeps remote branch)
71- uv run --from just-bin just wt-rm my-feature
78+ ``` bash
79+ just wt-add bugfix # another branch, another directory
80+ just wt-ls # see all active worktrees
81+ ```
7282
73- # Or nuke everything: worktree + local + remote branch
74- uv run --from just-bin just wt-destroy my-feature
83+ When a branch is merged, clean up:
84+
85+ ``` bash
86+ just wt-rm my-feature # removes worktree + local branch
87+ just wt-destroy bugfix # also deletes the remote branch
7588```
7689
77- The ` main/ ` worktree stays pristine as a clean reference for diffing. Never edit files in it
78- directly.
90+ To pull the latest changes into your local main:
91+
92+ ``` bash
93+ just wt-update # fetches all remotes, fast-forwards main
94+ ```
7995
8096## Updating a scaffolded project
8197
@@ -122,6 +138,11 @@ outside version control.
122138| ` wt-destroy ` | ` just wt-destroy <branch> ` | Remove a worktree and delete both local and remote branches. |
123139| ` wt-ls ` | ` just wt-ls ` | List all active worktrees. |
124140| ` wt-update ` | ` just wt-update ` | Fetch all remotes and fast-forward ` main ` . |
141+ | ` repo-clone ` | ` just repo-clone <owner/repo> ` | Clone a GitHub repo as a bare ` .git/ ` and create the ` main ` worktree. |
142+ | ` repo-init ` | ` just repo-init ` | Initialize a bare ` .git/ ` repo with an empty commit and ` main ` worktree. |
143+ | ` repo-create ` | ` just repo-create <owner/repo> [visibility] ` | Create a GitHub repo (default: private) and push ` main ` . |
144+ | ` repo-public ` | ` just repo-public ` | Change the GitHub repo's visibility to public. |
145+ | ` repo-private ` | ` just repo-private ` | Change the GitHub repo's visibility to private. |
125146| ` template-update ` | ` just template-update [args] ` | Update template files via copier. |
126147
127148## Local excludes
@@ -130,18 +151,6 @@ Files at the project root are outside version control. They're excluded via
130151` .git/info/exclude ` (not ` .gitignore ` ). To add your own patterns, edit
131152` .git/info/exclude ` directly.
132153
133- ## Known issues
134-
135- ### Starship shows branch name at the project root
136-
137- [ Starship] ( https://starship.rs/ ) 's ` git_branch ` module reads ` .git/HEAD ` and displays the
138- branch name even at the bare repo root. The ` ignore_bare_repo ` option doesn't help because
139- Starship uses [ gitoxide] ( https://github.com/GitoxideLabs/gitoxide ) which
140- [ has a bug detecting bare repos] ( https://github.com/GitoxideLabs/gitoxide/issues/2402 ) .
141-
142- The fix has been merged in gitoxide and is expected in the gitoxide release on 2026-02-22,
143- after which Starship needs to bump its gitoxide dependency.
144-
145154## Credit
146155
147156Based on the workflow from Ahmed el Gabri:
0 commit comments