packagemainimport("log"git"github.com/purpleclay/gitz")funcmain(){client,_:=git.NewClient()// all changes have been staged and committed locally_,err:=client.Push()iferr!=nil{log.Fatal("failed to push committed changes to the remote")}}
packagemainimport("log"git"github.com/purpleclay/gitz")funcmain(){client,_:=git.NewClient()// modifications are made to multiple files across two// different branches//// b: new-feature// > client.go// b: new-bug-fix// > parser.go_,err:=client.Push(git.WithAllBranches())iferr!=nil{log.Fatal("failed to stage files")}}
packagemainimport("log"git"github.com/purpleclay/gitz")funcmain(){client,_:=git.NewClient()// multiple tags are created locally, 1.0.0 and v1_,err:=client.Push(git.WithAllTags())iferr!=nil{log.Fatal("failed to stage files")}}
The WithRefSpecs option provides greater freedom to cherry-pick locally created references (branches and tags) and push them back to the remote. A reference can be as simple as a name or as explicit as providing a source (local) to destination (remote) mapping. Please read the official git specification on how to construct refspecs.
packagemainimport("log"git"github.com/purpleclay/gitz")funcmain(){client,_:=git.NewClient()// new branch and tag are created locally_,err:=client.Push(git.WithRefSpecs("0.1.0","new-branch"))iferr!=nil{log.Fatal("failed to stage files")}}
packagemainimport("log"git"github.com/purpleclay/gitz")funcmain(){client,_:=git.NewClient()// all changes have been staged and committed locally_,err:=client.Push(git.WithPushOptions("ci.skip=true"))iferr!=nil{log.Fatal("failed to push committed changes to the remote")}}
packagemainimport("log"git"github.com/purpleclay/gitz")funcmain(){client,_:=git.NewClient()// a tag and branch have been deleted locally_,err:=client.Push(git.WithDeleteRefSpecs("branch","0.1.0"))iferr!=nil{log.Fatal("failed to delete references from the remote")}}
You can provide git config through the WithPushConfig option to only take effect during the execution of a Push, removing the need to change config permanently.