gitgo-git

How to checkout latest release tag


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?


Solution

  • 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,
    })