-
Notifications
You must be signed in to change notification settings - Fork 5.9k
git: Add git worktree picker #38719
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
git: Add git worktree picker #38719
Conversation
|
Any chance of this being a zed extension rather than integrated straight to core? I only ask because I think that would be the faster way to get this and I really want to use it :) |
|
Hey @nwalke currently zed does not support that kind of extensions. And even if it does, I don't think it would be a good idea to move this to an extension. Zed already has git support so improving that support is the right choice imo. I don't think it should take too long for a zed team member to review this (and hopefully, aprove it), of course you can always compile this branch from source and use it (at your own risk). |
38ba2fc to
05d0621
Compare
|
Oh nice! I was trying to make an extension myself but I ran into the same issues, and then I stumbled upon this pull request. My only suggestion is adding |
|
I'll probably add worktree remove on another PR just because I'm not sure about the UI/UX for that functionality. For now, I think this PR is ready to go. |
75d8e1d to
6fbbd6c
Compare
5f91c94 to
da9a09c
Compare
da9a09c to
af7c99f
Compare
cole-miller
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @AlvaroParker, nice work and sorry for the delay in reviewing--this looks generally good, the only blocker I've noticed is the handling of opening worktrees in remote projects.
69f40b9 to
d115042
Compare
|
Thanks! In the latest revision it seems like opening remote worktrees isn't quite working--when I select a worktree from the picker I get a window with the original remote project, not a project for the selected worktree. Based on how |
|
I was hoping in reusing the connection of the active projects when on remote, but when I try creating a new remote |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, nice work on this! Just merging main manually to confirm there aren't any semantic merge conflicts here.
Related discussions zed-industries#26084 Worktree creations are implemented similar to how branch creations are handled on the branch picker (the user types a new name that's not on the list and a new entry option appears to create a new branch with that name). https://github.com/user-attachments/assets/39e58983-740c-4a91-be88-57ef95aed85b With this picker you have a few workflows: - Open the picker and type the name of a branch that's checked out on an existing worktree: - Press enter to open the worktree on a new window - Press ctrl-enter to open the worktree and replace the current window - Open the picker and type the name of a new branch or an existing one that's not checked out in another worktree: - Press enter to create the worktree and open in a new window. If the branch doesn't exists, we will create a new one based on the branch you have currently checked out. If the branch does exists then we create a worktree with that branch checked out. - Press ctrl-enter to do everything on the previous point but instead, replace the current window with the new worktre. - Open the picker and type the name of a new branch or an existing one that's not checked out in another worktree: - If a default branch is detected on the repo, you can create a new worktree based on that branch by pressing ctrl-enter or ctrl-shift-enter. The first one will open a new window and the last one will replace the current one. Note: If you preffer to not use the system prompt for choosing a directory, you can set `"use_system_path_prompts": false` in zed settings. Release Notes: - Added git worktree picker to open a git worktree on a new window or replace the current one - Added git worktree creation action --------- Co-authored-by: Cole Miller <[email protected]>
|
Awesome! One thing I've notice just now (that I didn't catch), is that when the following happens:
The worktree fails to create because there's already a branch Should we handle this edge case? Or is the error ok to have? Since the user is trying to create a branch that already exists but based off another branch. This doesn't happens if the user creates a worktree |
|
Awesome, thanks @AlvaroParker |
|
OMG THIS IS AWESOME!!!!! So cool |
Related discussions zed-industries#26084 Worktree creations are implemented similar to how branch creations are handled on the branch picker (the user types a new name that's not on the list and a new entry option appears to create a new branch with that name). https://github.com/user-attachments/assets/39e58983-740c-4a91-be88-57ef95aed85b With this picker you have a few workflows: - Open the picker and type the name of a branch that's checked out on an existing worktree: - Press enter to open the worktree on a new window - Press ctrl-enter to open the worktree and replace the current window - Open the picker and type the name of a new branch or an existing one that's not checked out in another worktree: - Press enter to create the worktree and open in a new window. If the branch doesn't exists, we will create a new one based on the branch you have currently checked out. If the branch does exists then we create a worktree with that branch checked out. - Press ctrl-enter to do everything on the previous point but instead, replace the current window with the new worktre. - Open the picker and type the name of a new branch or an existing one that's not checked out in another worktree: - If a default branch is detected on the repo, you can create a new worktree based on that branch by pressing ctrl-enter or ctrl-shift-enter. The first one will open a new window and the last one will replace the current one. Note: If you preffer to not use the system prompt for choosing a directory, you can set `"use_system_path_prompts": false` in zed settings. Release Notes: - Added git worktree picker to open a git worktree on a new window or replace the current one - Added git worktree creation action --------- Co-authored-by: Cole Miller <[email protected]>
Related discussions #26084
Worktree creations are implemented similar to how branch creations are handled on the branch picker (the user types a new name that's not on the list and a new entry option appears to create a new branch with that name).
2025-09-23.17-12-34.mp4
With this picker you have a few workflows:
Note: If you preffer to not use the system prompt for choosing a directory, you can set
"use_system_path_prompts": falsein zed settings.Release Notes: