Having trouble in running a go-git api example

364 views
Skip to first unread message

PK

unread,
Oct 17, 2022, 7:16:12 AM10/17/22
to golang-nuts
Hi,
I am trying to run example provided here(https://github.com/go-git/go-git/tree/master/_examples)

1) firstly I run the clone example by cloning a repo(https://github.com/go-git/go-git/blob/master/_examples/clone/auth/basic/access_token/main.go). (it was successful)

2) Then I run the commit example by creating a file.(https://github.com/go-git/go-git/blob/master/_examples/commit/main.go) it was successful.

3) Now I want to push that file to git repo. but I am not able to understand what argument i should give along with the go executable file.(https://github.com/go-git/go-git/blob/master/_examples/push/main.go)
I tried by executing the following commands
  ./push/main github_repo_url

but it says repository does not exist.




Can anyone please help me this.
Thank you.

Gergely Brautigam

unread,
Oct 18, 2022, 12:58:27 AM10/18/22
to golang-nuts
Hello.

Did you set up any remotes for the folder that you are trying to push?

PK

unread,
Oct 18, 2022, 5:19:09 AM10/18/22
to golang-nuts
no, Do we need to set-up something. If yes can you please let me know?

Gergely Brautigam

unread,
Oct 18, 2022, 6:36:19 AM10/18/22
to PK, golang-nuts
On 2022. Oct 18., at 11:19, PK <princ...@gmail.com> wrote:

no, Do we need to set-up something. If yes can you please let me know?

Yep. Well, you are trying to push something to somewhere, right? So you need a remote set up which is usually origin. So just set up a remote and then you can push.
Of course if you have files then first you need to add those and then create a commit.

-- 
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/iXTfzw2Nbk0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/75be3583-2d96-42cc-8931-f97ac5cf1c93n%40googlegroups.com.

PK

unread,
Oct 18, 2022, 6:45:10 AM10/18/22
to golang-nuts
Thank you, I tried to setup by this:

if err_psh = repo.Push(&git.PushOptions{

       RemoteName: "origin",

   }); err != nil {

       log.Fatal(err_psh)

   }

Then also the error is same.

This is fine right  ./push/main https://github.com/ravi-kp/graphProperties.git

Gergely Brautigam

unread,
Oct 18, 2022, 6:46:54 AM10/18/22
to PK, golang-nuts
Do you know how git works? You need a remote url for the repository to push to.

Reply all
Reply to author
Forward
0 new messages