Skip to content

getBranchCommit fails with Error: Reference 'refs/remotes/<branch>/HEAD' not found #992

@codeimpossible

Description

@codeimpossible

Been trying to get branch switching working but I'm not having any luck. I found #523 and i think i'm using the right api calls, but every time I try this code with a non-master branch, it fails with the error mentioned in the title.

Not sure if it matters, but the repo I've been testing with is http://github.com/codeimpossible/Artigo. I've been trying to switch from master, to the gh-pages branch.

    let repository;
    let fetch = git.Repository.open('path/to/local/repo');

    return fetch.then((repo) => {
      repository = repo;
      return repo.fetchAll();
    })
    .then(() => repository.getBranchCommit('non-master-branch'))
    .then((commit) => git.Branch.create(repository, 'non-master-branch', commit, true))
    .then(() => repository.checkoutBranch('non-master-branch'))

Also, I've tried calling Repository#getReference directly and that fails as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions