atom/git-utils

Repository::checkoutReference doesn't work with remote or tag references

Opened this issue · 0 comments

Redirected here from atom/atom#7973

The following works just fine

repository.checkoutReference('refs/heads/branch');

But when I have a remote branch named remote-branch on the origin remote and I try

repository.checkoutReference('refs/remotes/origin/remote-branch');

It fails to check out the remote branch. The same is true for tags. Apparently, it will only check out local branches:

Repository::checkoutReference = (branch, create)->
  if branch.indexOf('refs/heads/') isnt 0
    branch = "refs/heads/#{branch}"

  @checkoutRef(branch, create)

What's the reason for this?