nodejs/node · error · Exception
Couldn't find curent branch.
Error message
Couldn't find curent branch.
What it means
GitCurrentBranch parses `git status -s -b -uno` and looks for a line matching `^## (.+)` (the branch-tracking summary). If no such line appears, the repo is in a state without a current branch (detached HEAD, empty/unborn repo, or cwd is not a git worktree).
Source
Thrown at deps/v8/tools/release/git_recipes.py:162
def GitChangedFiles(self, git_hash, **kwargs):
assert git_hash
try:
files = self.Git(MakeArgs(["diff --name-only",
git_hash,
"%s^" % git_hash]), **kwargs)
return map(str.strip, files.splitlines())
except GitFailedException: # pragma: no cover
# Git fails using "^" at branch roots.
return []
@Strip
def GitCurrentBranch(self, **kwargs):
for line in self.Git("status -s -b -uno", **kwargs).strip().splitlines():
match = re.match(r"^## (.+)", line)
if match: return match.group(1)
raise Exception("Couldn't find curent branch.") # pragma: no cover
@Strip
def GitLog(self, n=0, format="", grep="", git_hash="", parent_hash="",
branch="", path=None, reverse=False, **kwargs):
assert not (git_hash and parent_hash)
args = ["log"]
if n > 0:
args.append("-%d" % n)
if format:
args.append("--format=%s" % format)
if grep:
args.append("--grep=\"%s\"" % grep.replace("\"", "\\\""))
if reverse:
args.append("--reverse")
if git_hash:
args.append(git_hash)
if parent_hash:
args.append("%s^" % parent_hash)View on GitHub (pinned to 1b2de5e052)
Solutions
- Check out a real branch: `git switch -c <branch>` or `git checkout <branch>`.
- Avoid running release scripts on a detached HEAD.
- Confirm the cwd is inside the right worktree (has a .git).
Example fix
// before # repo is in detached HEAD v8/tools/release/push_to_candidates.py ... // after git checkout main v8/tools/release/push_to_candidates.py ...
Defensive patterns
Strategy: validation
Validate before calling
import subprocess
out = subprocess.run(['git', 'status', '-s', '-b', '-uno'],
capture_output=True, text=True, check=True).stdout
assert any(line.startswith('## ') for line in out.splitlines()), (
'no current branch; check out a branch (not detached HEAD)') Prevention
- Always check out a real branch before running release scripts.
- In CI, avoid detached-HEAD checkouts for branch-aware tooling.
- Verify cwd is inside the intended worktree.
When it happens
Trigger: Running release scripts on a detached HEAD, on a freshly-init'd repo with no commits, or outside any git worktree.
Common situations: CI checkout in detached-HEAD mode; release tooling run on a tag/SHA instead of a branch; wrong cwd; empty repo.
Related errors
- 'git %s' failed.
- Couldn't determine commit position for %s
- Retried too often. Giving up. Reason: %s
- Unexpected json output: %s
- Install git and ensure it's in your PATH.
AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13).
Data as JSON: /api/errors/6e7eedaeddd7f58d.
Report an issue: GitHub.