Stage changes to a particular file or folder within the current repository for inclusion within the next commit. Staging is a prerequisite to committing and pushing changes back to the repository remote.
By default, all files (tracked and untracked) within the current repository are staged automatically unless explicitly ignored through a .gitignore file:
packagemainimport("log"git"github.com/purpleclay/gitz")funcmain(){client,_:=git.NewClient()// create multiple files within the following hierarchy:// > a.txt// > b.txt_,err:=client.Stage()iferr!=nil{log.Fatal("failed to stage all files")}}
packagemainimport("log"git"github.com/purpleclay/gitz")funcmain(){client,_:=git.NewClient()// create multiple files within the following hierarchy:// > root.txt// > folder// > a.txt// > b.txt_,err:=client.Stage(git.WithPathSpecs("root.txt","folder/a.txt"))iferr!=nil{log.Fatal("failed to stage files")}}
And to verify the staged changes:
$ git status --porcelain
A folder/a.txt
?? folder/b.txt
A root.txt