You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 11, 2020. It is now read-only.
Repository.Fetch is analogous to git fetch, so it will update references under refs/remotes/, but will leave you local branches and working directory unmodified.
Worktree.Pull is analogous to git pull and will fetch changes from the remote, update references in refs/remotes/, AND merge the changes into your current branch.
Here is an example of how to use the API:
package main
import (
"fmt"
"os"
"gopkg.in/src-d/go-git.v4"
. "gopkg.in/src-d/go-git.v4/_examples"
)
// Pull changes from a remote repository
func main() {
CheckArgs("<path>")
path := os.Args[1]
// We instance a new repository targeting the given path (the .git folder)
r, err := git.PlainOpen(path)
CheckIfError(err)
// Get the working directory for the repository
w, err := r.Worktree()
CheckIfError(err)
// Pull the latest changes from the origin remote and merge into the current branch
Info("git pull origin")
err = w.Pull(&git.PullOptions{RemoteName: "origin"})
CheckIfError(err)
// Print the latest commit that was just pulled
ref, err := r.Head()
CheckIfError(err)
commit, err := r.CommitObject(ref.Hash())
CheckIfError(err)
fmt.Println(commit)
}
I want to pull the latest files from git repo, but I don't know how to do this, can anybody tell me? thanks.
I can clone a repo:
rep, cloneErr := git.PlainClone(LOCAL_CLONE_PATH, false, &git.CloneOptions{
URL: GIT_REP_URL,
Progress: os.Stdout,
})
but did not find any API of pull request, just find a fetch API, but not work well
repo, openErr := git.PlainOpen(LOCAL_CLONE_PATH)
pullError := repo.Fetch(&git.FetchOptions{
RemoteName: "origin",
Progress: os.Stdout,
})
after run the fetch API, nothing changed in my local repo.
The text was updated successfully, but these errors were encountered: