go-git icon indicating copy to clipboard operation
go-git copied to clipboard

How to create a new repo programmatically

Open rjdsd opened this issue 5 years ago • 0 comments

I am trying to create a new Repo through this API on bitbucket

Following is the pseudocode

       newRepoURL :=  "ssh://git@ourbitbucket:port/myproject/myApp.git"
       r, err := git.PlainInit(newRepoURL, false)
       w, err := r.Worktree()
       filename := filepath.Join(newRepoURL, "example-git-file")
       _, err = w.Add("example-git-file")
       commit, err := w.Commit("init commit to new repo", &git.CommitOptions{
                                 Auth : auth
                                 }
        remote, err := r.CreateRemote(&config.RemoteConfig{
			Name: "myApp",
			URLs: []string{newRepoURL},
		         })
        err = remote.Push(&git.PushOptions{
			RemoteName: "myApp",
			Auth:auth,
		         }) 

But I get following error

unknown error: Repository not found

Could anyone help where I am going wrong here.

rjdsd avatar Jan 24 '20 02:01 rjdsd