pulumi/pulumi · error

no git repository found from

Error message

no git repository found from %v

What it means

GetGitHubProjectForOrigin returns "no git repository found from %v" when GetGitRepository yields a nil repository (no .git directory was found anywhere up from dir, or go-git reported the repository does not exist). Note the check order in the source: repo == nil is tested before err, so this message also surfaces when err is non-nil and repo is nil; the wrapped underlying error is available via the err return. It signals that owner/repo VCS info cannot be derived because there is no repository at or above the given directory.

Solutions

  1. Run the command from inside a directory that is part of a git clone (verify with git rev-parse --show-toplevel).
  2. Initialize the repository if it should be one: git init (and add the origin remote: git remote add origin <url>).
  3. In CI, check out the repository with git (e.g. actions/checkout) instead of downloading artifacts, so .git exists.
  4. In code, call GetGitRepository first and handle the nil-repo case explicitly before calling GetGitHubProjectForOrigin.

Example fix

// before
info, err := gitutil.GetGitHubProjectForOrigin(dir) // "no git repository found from ..."
// after
repo, err := gitutil.GetGitRepository(dir)
if err != nil {
	return err
}
if repo == nil {
	return fmt.Errorf("%s is not a git repository; run 'git init' or run from a checkout", dir)
}
info, err := gitutil.GetGitHubProjectForOrigin(dir)
Defensive patterns

Strategy: validation

Validate before calling

cmd := exec.Command("git", "-C", dir, "rev-parse", "--show-toplevel")
if err := cmd.Run(); err != nil {
	return fmt.Errorf("%s is not inside a git repository; run from a checkout or run 'git init'", dir)
}

Try / catch

info, err := gitutil.GetGitHubProjectForOrigin(dir)
if err != nil && strings.HasPrefix(err.Error(), "no git repository found") {
	return fmt.Errorf("run this command from inside a git clone of your project")
} else if err != nil {
	return err
}

Prevention

When it happens

Trigger: Calling gitutil.GetGitHubProjectForOrigin(dir) where dir is outside any git repository (no .git found up to the filesystem root), or the found .git exists but PlainOpenWithOptions returned ErrRepositoryNotExists (mapped to nil, nil).

Common situations: Running the tool in a freshly created, non-git project directory; operating on an extracted archive or temp copy of a project without the .git folder; running in CI from a downloaded artifact instead of a checkout; cwd pointing at $HOME or /tmp.

Related errors


AI-assisted analysis of pulumi/pulumi@793f7b2e16 (2026-08-31). Data as JSON: /api/errors/9455ec480af8cc9b. Report an issue: GitHub.

Appendix: source

Thrown at sdk/go/common/util/gitutil/git.go:115

	}

	// Open the git repo in the .git folder's parent, not the .git folder itself.
	repo, err := git.PlainOpenWithOptions(filepath.Dir(gitRoot), &git.PlainOpenOptions{})
	if errors.Is(err, git.ErrRepositoryNotExists) {
		return nil, nil
	}
	if err != nil {
		return nil, fmt.Errorf("reading git repository: %w", err)
	}
	return repo, nil
}

// GetGitHubProjectForOrigin returns the GitHub login, and GitHub repo name if the "origin" remote is
// a GitHub URL.
func GetGitHubProjectForOrigin(dir string) (*VCSInfo, error) {
	repo, err := GetGitRepository(dir)
	if repo == nil {
		return nil, fmt.Errorf("no git repository found from %v", dir)
	}
	if err != nil {
		return nil, err
	}
	remoteURL, err := GetGitRemoteURL(repo, "origin")
	if err != nil {
		return nil, err
	}
	return TryGetVCSInfo(remoteURL)
}

// GetGitRemoteURL returns the remote URL for the given remoteName in the repo.
func GetGitRemoteURL(repo *git.Repository, remoteName string) (string, error) {
	remote, err := repo.Remote(remoteName)
	if err != nil {
		return "", fmt.Errorf("could not read origin information: %w", err)
	}

View on GitHub (pinned to 793f7b2e16)