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

Setting to specify worktree path #18

Closed BrianKmdy closed 1 year ago

BrianKmdy commented 1 year ago

Is there a setting to specify where worktrees should be stored? I think it would be useful to have a directory somewhere out of the way to put all the active worktrees

alexiszamanidis commented 1 year ago

The basic idea is to create all worktrees at the same repository level. A simple solution is to use bare repositories or create a directory for your repository and keep all your worktrees there.

Am I missing something? Why would you want to specify a different path for your worktrees?

BrianKmdy commented 1 year ago

Right now I have all my repositories in d:/projects, I guess my concern would be if all of my active worktrees are also in d:/projects it would start to get kind of cluttered as I would have all of my repositories and worktrees mixed in the same project directory.

I was thinking it would be nice being able to store all worktrees for all projects in d:/projects/worktrees. But I could also look into your suggestions and try a bare repository or creating a subfolder that would include a repository and its worktrees.

alexiszamanidis commented 1 year ago

My personal preference is to use bare repositories. That's what I recommend to people who use work trees.

I'm not sure how you would solve the problem that happens in the project directory by creating a directory of worktrees. You will end up creating multiple worktrees from multiple projects in the same directory.

BrianKmdy commented 1 year ago

I tried working with bare repositories but I think there's still a use case for specifying a worktree directory. My current workflow involves having a primary vscode window with all of my active projects. The issue I found with bare repositories is that it's a bit more complicated to set up and the directory name I'm adding to my workspace ends up being the name of a branch, i.e. "main". This makes it difficult to differentiate projects in that window.

I personally don't mind mixing and matching the worktrees from all my active projects into a single folder.

alexiszamanidis commented 1 year ago

Hmm... If that's the case, I'll add a configurable property. When this property is defined, all worktrees will be created based on your path.

BrianKmdy commented 1 year ago

That would be awesome, thank you!

alexiszamanidis commented 1 year ago

Hi @BrianKmdy,

Apologies for the delay!

The enhancement has been published v1.0.21!

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.

BrianKmdy commented 1 year ago

Awesome, thank you @alexiszamanidis. I tested it out and it I'm able to store my worktrees in the folder now! One note which relates to this issue (https://github.com/alexiszamanidis/vscode-git-worktrees/issues/19) is that the worktree name doesn't include the project name, so if I had worktrees from multiple projects in that same folder there could be name collisions if they use the same branch name.

Thanks again for working on this!

alexiszamanidis commented 1 year ago

To avoid name collisions, the format should look something like this:

[base-path]/[project-directory]/[worktree-name]

How does this sound to you?

BrianKmdy commented 1 year ago

That looks perfect to me

alexiszamanidis commented 1 year ago

I added the enhancement.

I hope you like it!

BrianKmdy commented 1 year ago

I just tried it out - this is perfect, thank you! This is exactly what I was looking for.

alexiszamanidis commented 1 year ago

You are welcome!

I'm glad you liked it.

Thank you for your time and contribution!