alexiszamanidis / vscode-git-worktrees

A VS Code extension that wraps git worktree operations for simplicity and productivity
https://marketplace.visualstudio.com/items?itemName=GitWorktrees.git-worktrees
MIT License
44 stars 5 forks source link

Feature Request: Git Worktree: Add: Match remote branch name and make new branch name optional #16

Closed tomoum closed 1 year ago

tomoum commented 1 year ago

First off thanks for this awesome tool!

Feature Request: I find that specifying the new branch name every time I want to add a new worktree is quite annoying. It would be much nicer if that flow works similar to the gitlens worktree feature in that it just shows me the remotes and I can choose one right away and then use the branch name as the folder name. You would need to process the branch name and replace / with - in order to keep all clones just one folder deep. However, it would be fine to do it like git lens and create subfolders that match the branch name.

E.g:

  1. Command Palette -> Git Worktree: Add
  2. (Optional) new branch name if the user specifies one then it works just as how it does right now. However, if they leave this empty, then use the selection in step 3 to create the folder structure.
  3. Select a remote branch -> feature/upgrade-libs
  4. If no new branch name is specified then match the remote by creating {worktree_root}/feature-upgrade-libs/{repo_cloned_here}

I hope this is clear. I think it would be an easier way to clone remotes that match the remote branch name by default.

Thanks EDIT: I realize now that maybe the intent of this is different. Maybe this would be a difference command called Git Worktree: Checkout.

alexiszamanidis commented 1 year ago

Hi @tomoum, I am glad you like the extension.

Sorry for the delay, but I've been on the run for the past few days.

Concerning the level of the worktrees, your idea about replacing / with - is good. I will look into it as another feature where users would be able to create a worktree based on their preferences. It will be configurable based on the vscode properties.

From my understanding, one solution would be the Git Worktree: Checkout you suggested. The other one would be to change the flow of the Git Worktree: Add operation to show you first the remote branches, select a remote branch, then type the new worktree name or press ESC to cancel the operation.

Would that be something you like? Or have I misunderstood something?

tomoum commented 1 year ago

yes, that would be amazing. Either of those would be great additions! that would be much appreciated! thanks, @alexiszamanidis

grooc commented 1 year ago

I am also interested in the suggested feature! "to change the flow of the Git Worktree: Add operation to show you first the remote / existing branches"

Sometimes i think this will be just a small change, so i don't create a worktree for it, but later the change requires more rework, and i want to create a worktree with an existing feature branch. I also like the suggestion to use a remote branch for creating a new worktree!

alexiszamanidis commented 1 year ago

Hi @grooc,

This is an excellent idea. So, in the first step, we will list all the local and remote branches and have something like this: master, origin/master.

I will definitely adjust it in the implementation.

alexiszamanidis commented 1 year ago

Hi guys(@tomoum, @grooc),

Apologies for the delay!

The enhancement has been published v1.0.21!

I have changed the flow of the git worktree add operation.

I would really like to know if this enhancement was what you were looking for.

Please test it when you are free and let me know about your experience.

P.S. @grooc for the local branches, please check what I responded to you about it here #21

tomoum commented 1 year ago

This is perfect now. Works like a charm. This is exactly what I wanted. Thanks @alexiszamanidis !! great job!

alexiszamanidis commented 1 year ago

I'm glad you liked it.

Thank you for your time and contribution.