go-git icon indicating copy to clipboard operation
go-git copied to clipboard

fetch or pull not getting latest commits from forked repo

Open joaquin-gimenez opened this issue 6 years ago • 0 comments

how do fetch and pull work? do they get latest commit independent of a new release version/tag? cause i can't see why this is happening. I know fetch should get latest to remotes/origin/master but it's not happening

repo, err := git.PlainOpen(repoDir) err = repo.Fetch(&git.FetchOptions{ RemoteName: git.DefaultRemoteName, Tags: git.AllTags, Force: true, RefSpecs: []git_config.RefSpec{"+refs/heads/:refs/remotes/origin/"}, Depth: 2, }) workdir, _ := repo.Worktree()

refName := "refs/remotes/" + git.DefaultRemoteName + "/master"

head, _ := repo.Head()

if head.Hash() == ref.Hash() { //they are same }

joaquin-gimenez avatar Sep 26 '19 15:09 joaquin-gimenez