src-d / go-git

Project has been moved to: https://github.com/go-git/go-git
https://github.com/go-git/go-git
Apache License 2.0
4.91k stars 541 forks source link

fetch or pull not getting latest commits from forked repo #1221

Open joaquin-gimenez opened 5 years ago

joaquin-gimenez commented 5 years ago

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: []gitconfig.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 }