Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我知道如何使用Checkout(&git.checkoutOptions)with plumbing.ReferenceName("<branchName>")or签出特定的提交或分支plumbing.Hash("<commit hash>"),但我希望能够克隆特定的发布版本。关于如何做到这一点的任何想法?
Checkout(&git.checkoutOptions)
plumbing.ReferenceName("<branchName>")
plumbing.Hash("<commit hash>")
您需要在 CloneOptions 中设置 ReferenceName。
git-go 的克隆 v4.1 示例:
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, })