Problem Statement
An empty folder is the most natural starting point when using dotbot to scaffold a new project. But if the folder has been git init-ed with no commits yet, dotbot crashes immediately with a cryptic git error and no recovery path. The user has to know — unprompted — to create a manual initial commit before running any workflow. This happens on every new project, the error message gives no hint about the cause, and the workaround is not surfaced anywhere in the CLI output.
How to Reproduce
mkdir my-new-project && cd my-new-project
git init # creates unborn HEAD on 'master', no commits
dotbot init # seeds .bot/workspace + .gitignore
# start any workflow (e.g. azure-to-github) and run the first task
Observe:
⚠ Branch guard warning: Cannot find base branch in C:\code\my-new-project
✗ Task failed unexpectedly: Worktree setup failed for task 'Fetch Work Item':
Failed to create worktree: git worktree add failed:
fatal: invalid reference: task/t_mvsYTO-fetch-work-item
✗ Mandatory task failed: Fetch Work Item - stopping workflow
There is no mention of "no commits" or what to do next.
Original Report
Summary
Starting any workflow in a brand-new dotbot project fails on the very first task. If the project's git repo has been git init'd but has no commits yet (unborn HEAD), worktree creation aborts with a cryptic git error and the workflow stops immediately.
Since v4 removed skip_worktree and every task now runs in a git worktree, this blocks the first run of a fresh project entirely — there is no longer a non-worktree path that would have sidestepped it.
Environment
|
|
| dotbot version |
4.0.0 |
| Platform |
Windows 11 |
| git |
2.31.1.windows.1 |
| Project repo |
freshly git init'd, default branch master, 0 commits |
Root Cause
In src/runtime/Modules/Dotbot.Worktree/Dotbot.Worktree.psm1, Resolve-DotbotBaseBranch uses git rev-parse --verify to confirm a branch exists. On an unborn repo, master is a symbolic ref with no commit — rev-parse --verify fails, the function returns $null, and Assert-OnBaseBranch throws "Cannot find base branch".
The module already has Test-RepositoryHasCommits and Resolve-UnbornBaseBranch helpers for this exact case, but they are never called from the worktree-creation path. The fix is already half-written but not wired in.
Preferred fix
When Test-RepositoryHasCommits returns $false, auto-create an empty initial commit before the first git worktree add:
git commit --allow-empty -m "chore: initial commit"
This makes git init + dotbot init + dotbot workflow run work end-to-end with no manual steps.
Minimum fix
If auto-commit is not acceptable, fail fast with a clear message and the exact command to run — not the current cryptic Cannot find base branch / fatal: invalid reference chain.
Workaround (current)
git add -A && git commit -m "chore: initial commit"
# or
git commit --allow-empty -m "init"
Note
Supersedes #513 — original was closed with the workaround above documented in a comment, but no code was changed. Confirmed recurring across multiple users on every new project start.
Problem Statement
An empty folder is the most natural starting point when using dotbot to scaffold a new project. But if the folder has been
git init-ed with no commits yet, dotbot crashes immediately with a cryptic git error and no recovery path. The user has to know — unprompted — to create a manual initial commit before running any workflow. This happens on every new project, the error message gives no hint about the cause, and the workaround is not surfaced anywhere in the CLI output.How to Reproduce
Observe:
There is no mention of "no commits" or what to do next.
Original Report
Summary
Starting any workflow in a brand-new dotbot project fails on the very first task. If the project's git repo has been
git init'd but has no commits yet (unbornHEAD), worktree creation aborts with a cryptic git error and the workflow stops immediately.Since v4 removed
skip_worktreeand every task now runs in a git worktree, this blocks the first run of a fresh project entirely — there is no longer a non-worktree path that would have sidestepped it.Environment
4.0.02.31.1.windows.1git init'd, default branchmaster, 0 commitsRoot Cause
In
src/runtime/Modules/Dotbot.Worktree/Dotbot.Worktree.psm1,Resolve-DotbotBaseBranchusesgit rev-parse --verifyto confirm a branch exists. On an unborn repo,masteris a symbolic ref with no commit —rev-parse --verifyfails, the function returns$null, andAssert-OnBaseBranchthrows"Cannot find base branch".The module already has
Test-RepositoryHasCommitsandResolve-UnbornBaseBranchhelpers for this exact case, but they are never called from the worktree-creation path. The fix is already half-written but not wired in.Preferred fix
When
Test-RepositoryHasCommitsreturns$false, auto-create an empty initial commit before the firstgit worktree add:This makes
git init+dotbot init+dotbot workflow runwork end-to-end with no manual steps.Minimum fix
If auto-commit is not acceptable, fail fast with a clear message and the exact command to run — not the current cryptic
Cannot find base branch/fatal: invalid referencechain.Workaround (current)
Note
Supersedes #513 — original was closed with the workaround above documented in a comment, but no code was changed. Confirmed recurring across multiple users on every new project start.