go-git
go-git copied to clipboard
How to create a new repo programmatically
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.