# Support checking out remote HEAD refs \(\#57648\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/c35650a88476587c9272eede79a2960d143b5a59)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: c35650a88476587c9272eede79a2960d143b5a59

Requested commit: c35650a88476587c9272eede79a2960d143b5a59

Commit: c35650a88476587c9272eede79a2960d143b5a59

Tree: 3c565aac29f3debbefee82651611558d7c4e0839

Author: Albert Bogusz

Committer: GitHub

## Message

```
Support checking out remote HEAD refs (#57648)

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [ ] Unsafe blocks (if any) have justifying comments N/A
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Remote `HEAD` refs such as `origin/HEAD` and `upstream/HEAD` are
symbolic refs that point to a remote's default branch. These refs can
appear in the branch picker, but selecting them shows this error prompt:

![Error
Popup](https://github.com/user-attachments/assets/f30f9c9a-8f4e-43d9-8830-282eb17a3572)

This happens because the local branch name is directly derived from the
selected ref, resulting in an attempted checkout of a local branch named
`HEAD`.

This change follows up on feedback from #57588, which just filtered
remote `HEAD` refs out of the branch picker to prevent the error prompt.
As mentioned in [this
comment](https://github.com/zed-industries/zed/pull/57588#issuecomment-4533477336),
I agree that the preferred behaviour should be to instead allow checking
them out - useful for repos with multiple remotes such as an upstream.

For example, if `refs/remotes/origin/HEAD` points to
`refs/remotes/origin/main`, selecting `origin/HEAD` now behaves like
selecting `origin/main`, switching to the corresponding local `main`
branch instead of trying to create or check out a branch named `HEAD`.
This does not fetch or pull from the remote; it uses the locally known
remote refs.

Release Notes:

- Fixed selecting remote HEAD refs from the branch picker

---------

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
```

## Parents

- [15c31d4147fe8c5d12c1844bbba19d300ec2840e](https://git.cafe/gitcafe/zed/commit/15c31d4147fe8c5d12c1844bbba19d300ec2840e?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/c35650a88476587c9272eede79a2960d143b5a59?format=markdown)
