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

  1. Set an upstream: git push -u origin <branch> or git branch --set-upstream-to=origin/<branch>
  2. Confirm the ref resolves with `git rev-parse --symbolic-full-name @{upstream}`
  3. If the remote branch was deleted, choose another upstream or re-push
  4. 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

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


AI-assisted analysis of mislav/hub@5c547ed804 (2026-09-01). Data as JSON: /api/errors/6853bb3933d5a2cd. Report an issue: GitHub.