mislav/hub · error

Error: that fork is not available anymore

Error message

Error: that fork is not available anymore

What it means

When merging a pull request given by URL/number, `transformMergeArgs` fetches the PR and reads its head repository. If `pullRequest.Head.Repo` is nil, the fork backing the PR head has been deleted, so the branch can no longer be fetched. The command aborts before attempting `git fetch` on a nonexistent repo.

Source

Thrown at commands/merge.go:84

	pullRequest, err := gh.PullRequest(url.Project, id)
	if err != nil {
		return err
	}

	repo, err := github.LocalRepo()
	if err != nil {
		return err
	}

	remote, err := repo.RemoteForRepo(pullRequest.Base.Repo)
	if err != nil {
		return err
	}

	branch := pullRequest.Head.Ref
	headRepo := pullRequest.Head.Repo
	if headRepo == nil {
		return fmt.Errorf("Error: that fork is not available anymore")
	}

	args.Before("git", "fetch", remote.Name, fmt.Sprintf("refs/pull/%s/head", id))

	// Remove pull request URL
	idx := args.IndexOfParam(mergeURL)
	args.RemoveParam(idx)

	mergeMsg := fmt.Sprintf("Merge pull request #%s from %s/%s\n\n%s", id, headRepo.Owner.Login, branch, pullRequest.Title)
	args.AppendParams("FETCH_HEAD", "-m", mergeMsg)

	if args.IndexOfParam("--ff-only") == -1 && args.IndexOfParam("--squash") == -1 && args.IndexOfParam("--ff") == -1 {
		i := args.IndexOfParam("-m")
		args.InsertParam(i, "--no-ff")
	}

	return nil
}

View on GitHub (pinned to 5c547ed804)

Solutions

  1. Ask the PR author to restore their fork and reopen/refresh the PR.
  2. Have the author re-open a new PR from an existing branch/repo containing the same changes.
  3. Apply the changes manually (cherry-pick from a local clone of the fork if you have one) and merge via a new local branch.
  4. Close the PR if the changes are unavailable.

Example fix

// before
gh merge https://github.com/owner/repo/pull/123   // Head.Repo is nil
// after
# ask author to restore fork, then retry, or locally:
git remote add fork git@github.com:author/fork.git && git fetch fork branch && git merge fork/branch
Defensive patterns

Strategy: try-catch

Validate before calling

pr := fetchPullRequest(id)
if pr.Head.Repo == nil {
    fmt.Fprintln(os.Stderr, "PR head fork is gone; ask the author to restore it or merge manually")
    os.Exit(1)
}

Type guard

func headRepoAvailable(pr *github.PullRequest) bool {
    return pr.Head != nil && pr.Head.Repo != nil
}

Try / catch

err := runMerge(prNumber)
if err != nil && strings.Contains(err.Error(), "not available anymore") {
    // recover: add fork remote manually or cherry-pick into a local branch
    fmt.Fprintln(os.Stderr, "fork deleted; falling back to manual merge")
}

Prevention

When it happens

Trigger: Running `gh merge <pr-url-or-number>` where the fetched `github.PullRequest.Head.Repo` is nil — the contributor's fork was deleted (or the repo was made private/removed) after the PR was opened.

Common situations: Long-lived PRs whose author deleted their fork after closing other work; organizations that clean up contributor forks; PRs from branches on repos removed due to policy or inactivity.

Related errors


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