mislav/hub · error
Unknown revision or path not in the working tree: %s
Error message
Unknown revision or path not in the working tree: %s
What it means
SymbolicFullName() resolves a symbolic ref name (typically "@{upstream}") to its full ref path with `git rev-parse --symbolic-full-name <name>`. When rev-parse fails, the library replaces the underlying error with this message naming the input ref, meaning the name cannot be resolved as a revision or ref in the current repo.
Source
Thrown at git/git.go:136
func Head() (string, error) {
return SymbolicRef("HEAD")
}
// SymbolicRef reads a branch name from a ref such as "HEAD"
func SymbolicRef(ref string) (string, error) {
refCmd := gitCmd("symbolic-ref", ref)
refCmd.Stderr = nil
output, err := refCmd.Output()
return firstLine(output), err
}
// SymbolicFullName reads a branch name from a ref such as "@{upstream}"
func SymbolicFullName(name string) (string, error) {
parseCmd := gitCmd("rev-parse", "--symbolic-full-name", name)
parseCmd.Stderr = nil
output, err := parseCmd.Output()
if err != nil {
return "", fmt.Errorf("Unknown revision or path not in the working tree: %s", name)
}
return firstLine(output), nil
}
func Ref(ref string) (string, error) {
parseCmd := gitCmd("rev-parse", "-q", ref)
parseCmd.Stderr = nil
output, err := parseCmd.Output()
if err != nil {
return "", fmt.Errorf("Unknown revision or path not in the working tree: %s", ref)
}
return firstLine(output), nil
}
func RefList(a, b string) ([]string, error) {
ref := fmt.Sprintf("%s...%s", a, b)View on GitHub (pinned to 5c547ed804)
Solutions
- Set an upstream: git push -u origin <branch> or git branch --set-upstream-to=origin/<branch>
- Confirm the ref resolves with `git rev-parse --symbolic-full-name @{upstream}`
- If the remote branch was deleted, choose another upstream or re-push
- Check you are on a branch, not detached HEAD, before calling
Example fix
// before
full, err := git.SymbolicFullName("@{upstream}")
// after
full, err := git.SymbolicFullName("@{upstream}")
if err != nil {
return fmt.Errorf("branch has no upstream; run: git push -u origin %s", branch)
} Defensive patterns
Strategy: validation
Validate before calling
out, err := exec.Command("git", "rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{upstream}").Output()
hasUpstream := err == nil && len(strings.TrimSpace(string(out))) > 0 Try / catch
full, err := git.SymbolicFullName("@{upstream}")
if err != nil {
return fmt.Errorf("no upstream for current branch; run `git push -u origin <branch>`")
} Prevention
- Always push with -u to set upstream for new branches
- Verify upstream exists with git rev-parse @{upstream} before syncing
- Avoid @{upstream} on detached HEAD
- Prune stale remotes and re-set upstream after force-deletes
When it happens
Trigger: Calling git.SymbolicFullName("@{upstream}") (via sync or Upstream) when the current branch has no upstream configured, the upstream branch was deleted, or the ref name doesn't exist.
Common situations: New local branch never pushed (no upstream set); remote-tracking ref pruned after the remote branch was deleted; running on a detached HEAD where @{upstream} is meaningless.
Related errors
- the current branch '%s' doesn't seem pushed to a remote
- the branch to compare '%s' is the default branch
- the branch to compare '%s' is the same as --base
- Aborted: head branch is the same as base ("%s") (use `-h <br
- %s (use `-h <branch>` to specify an explicit pull request he
AI-assisted analysis of mislav/hub@5c547ed804 (2026-09-01).
Data as JSON: /api/errors/6853bb3933d5a2cd.
Report an issue: GitHub.