blob: 7f6d121d13ab230a2442990f8475d783a40445a8 [file] [log] [blame]
package main
import (
git ""
. ""
func main() {
CheckArgs("<url>", "<directory>", "<github_access_token>")
url, directory, token := os.Args[1], os.Args[2], os.Args[3]
// Clone the given repository to the given directory
Info("git clone %s %s", url, directory)
r, err := git.PlainClone(directory, false, &git.CloneOptions{
// The intended use of a GitHub personal access token is in replace of your password
// because access tokens can easily be revoked.
Auth: &http.BasicAuth{
Username: "abc123", // yes, this can be anything except an empty string
Password: token,
URL: url,
Progress: os.Stdout,
// ... retrieving the branch being pointed by HEAD
ref, err := r.Head()
// ... retrieving the commit object
commit, err := r.CommitObject(ref.Hash())