How to checkout latest release tag

734 Views Asked by At

I'm aware of how to checkout a specific commit or branch using Checkout(&git.checkoutOptions) with plumbing.ReferenceName("<branchName>") or plumbing.Hash("<commit hash>"), but I want to be able to clone a specific release version. Any ideas on how to do this?

1

There are 1 best solutions below

4
On BEST ANSWER

You will need to set ReferenceName in CloneOptions.

Example cloning v4.1 of git-go:

r, err := git.PlainClone("/tmp/foo", false, &git.CloneOptions{
        URL:      "https://github.com/go-git/go-git",
        ReferenceName: plumbing.ReferenceName("refs/tags/v4.1.0"),
        Progress: os.Stdout,
})