I have a repo which needs to be cloned daily for some data. Is there a way in golang using go-git library to clone the repo only once and update the repo using git pull?
Sure, there's Worktree.Pull()
method exactly for that.
// Open already cloned repo in path
r, err := git.PlainOpen(path)
// Get the working directory
w, err := r.Worktree()
// Pull from origin
err = w.Pull(&git.PullOptions{RemoteName: "origin"})
(skipped error checking for better readability)