Skip to content

PlainClone: reference not found #21

Closed

Description

@kamiyaa

I'm getting reference not found when I try to clone an empty repository.

...
log.Println("Parsing Private Key...")
signer, err := ssh.ParsePrivateKey([]byte(GOOGLE_ID_RSA))
if err != nil {
	log.Printf("Failed to parse key: %s",
		err.Error())
	return
}
log.Println("Done")

auth := &git_ssh.PublicKeys {
	User: "git",
	Signer: signer,
}
auth.HostKeyCallback = ssh.InsecureIgnoreHostKey()

clone_path := "/tmp/<reponame>"
clone_url := "ssh://<email>@source.developers.google.com:2022/p/<project>/r/<reponame>"

log.Printf("Cloning repo '%s' to '%s'...", clone_url, clone_path)
repo, err := git.PlainClone(clone_path, false, &git.CloneOptions{
	URL: clone_url,
	Progress: os.Stdout,
	Auth: auth,
})
if err != nil {
	log.Printf("Failed to clone repo: %s",
		err.Error())
	return
}
log.Println("Done")

log.Println("Getting working tree...")
work_tree, err := repo.Worktree()
...

Output:

2020/04/06 17:48:05 Decoding JSON...
2020/04/06 17:48:05 Done
2020/04/06 17:48:05 Parsing Private Key...
2020/04/06 17:48:05 Done
2020/04/06 17:48:05 Cloning repo 'ssh://<email>@source.developers.google.com:2022/p/<project>/r/<reponame>' to '/tmp/<reponame>'...
2020/04/06 17:48:06 Failed to clone repo: reference not found

I tried it on a different repo with an initial commit committed and it worked fine.

This is what I have imported:

	"github.com/go-git/go-git/v5"
	"github.com/go-git/go-git/v5/plumbing"
	git_ssh "github.com/go-git/go-git/v5/plumbing/transport/ssh"
	git_object "github.com/go-git/go-git/v5/plumbing/object"

Activity

  1. changed the title [-]reference not found[/-] [+]PlainClone: reference not found[/+] on Apr 6, 2020
  2. mcuadros commented on Apr 7, 2020

    @mcuadros
    Member

    BTW git_ssh.PublicKeys.User == <email>

  3. kamiyaa commented on Apr 7, 2020

    @kamiyaa
    Author

    BTW git_ssh.PublicKeys.User == <email>

    Oh my bad haha.
    Thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions