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

Created on 10 Apr 2016  路  4Comments  路  Source: nodegit/nodegit

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.

Most helpful comment

@johnhaley81 you are awesome. That worked!

All 4 comments

Possibly related to #797. What is the actual branch you're trying to check out? origin/gh-pages?

in the code above I used 'gh-pages' instead of 'non-master-branch'. Should i have used 'origin/gh-pages' instead?

Yeah, that should work.

@johnhaley81 you are awesome. That worked!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Means88 picture Means88  路  5Comments

DawsonG picture DawsonG  路  8Comments

mklueh picture mklueh  路  5Comments

seokju-na picture seokju-na  路  4Comments

fatso83 picture fatso83  路  7Comments