Skip to content
Discussion options

You must be logged in to vote

Hey @raffis this should work:

package main

import (
	"fmt"
	"io/ioutil"
	"os"
	"path/filepath"
	"time"

	"github.com/go-git/go-git/v5"
	. "github.com/go-git/go-git/v5/_examples"
	"github.com/go-git/go-git/v5/plumbing/format/config"
	"github.com/go-git/go-git/v5/plumbing/object"
)

func main() {
	CheckArgs("<directory>")
	directory := os.Args[1]

	os.RemoveAll(directory)

	// Init a new repository.
	r, err := git.PlainInit(directory)
	CheckIfError(err)

	w, err := r.Worktree()
	CheckIfError(err)

	// ... we need a file to commit so let's create a new file inside of the
	// worktree of the project using the go standard library.
	Info("echo \"hello world!\" > example-git-file")
	filename := f…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by raffis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants