Push method of go.git Repository does not push to remote

50 views Asked by At

At some point in my code I invoke the Push method of go-git

        refSpecStr := fmt.Sprintf(
            "+%s:refs/remotes/origin/%s",
            currentBranch.Name().String(),
            currentBranch.Name().Short(),
        )
        // perform git push
        pushOptions := git.PushOptions{
            RemoteName: "origin",
            Auth:       auth,
            RefSpecs:   []config.RefSpec{config.RefSpec(refSpecStr)},
        }
        if err = repo.Push(&pushOptions); err != nil {
            return fmt.Errorf("failed git push operation: %w", err)
        }
    }

The err is nil but the remote is never updated.

Any suggestions?

0

There are 0 answers