From 2c9007cd619ad0f09658a4c6da449acb5d80d8c5 Mon Sep 17 00:00:00 2001 From: Marc Czulewicz Date: Fri, 22 May 2026 10:26:54 -0400 Subject: [PATCH 1/2] Add WorktreeSubFolder option --- GitWorkTree/Options/General.cs | 8 +++++++- GitWorkTree/ViewModel/WorkTreeDialogViewModel.cs | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/GitWorkTree/Options/General.cs b/GitWorkTree/Options/General.cs index e9cf1c3..218cb27 100644 --- a/GitWorkTree/Options/General.cs +++ b/GitWorkTree/Options/General.cs @@ -10,6 +10,7 @@ public class GeneralOptions : BaseOptionPage { public bool IsLoadSolution { get; set; } public string DefaultWorktreeDirectory { get; set; } + public string WorktreeSubFolder { get; set; } } } @@ -22,8 +23,13 @@ public class General : BaseOptionModel [DisplayName("Default Worktree Directory: ")] - [Description("Path where new worktrees will be created. If empty, the current repository directory will be used.")] + [Description("Absolute path where new worktrees will be created. If empty (and Worktree Sub-Folder is also empty), worktrees default to a sibling \"_Worktrees\" folder.")] [DefaultValue("")] public string DefaultWorktreeDirectory { get; set; } + + [DisplayName("Worktree Sub-Folder: ")] + [Description("Folder name created inside each repository to hold its worktrees (e.g. \".worktrees\"). When set, takes precedence over Default Worktree Directory. Tip: add this folder to .gitignore.")] + [DefaultValue("")] + public string WorktreeSubFolder { get; set; } } } diff --git a/GitWorkTree/ViewModel/WorkTreeDialogViewModel.cs b/GitWorkTree/ViewModel/WorkTreeDialogViewModel.cs index 03a87f9..9b3ad6e 100644 --- a/GitWorkTree/ViewModel/WorkTreeDialogViewModel.cs +++ b/GitWorkTree/ViewModel/WorkTreeDialogViewModel.cs @@ -221,7 +221,13 @@ private async Task UpdateFolderPath() { if (!(commandType == CommandType.Create) || _selectedBranch_Worktree == null) return false; string worktreePath = Path.Combine(Directory.GetParent(_activeRepositoryPath).FullName, $"{_activeRepositoryPath}_Worktrees"); - string pathPrefix = String.IsNullOrEmpty(optionsSaved.DefaultWorktreeDirectory) ? $"{worktreePath}" : optionsSaved.DefaultWorktreeDirectory; + string pathPrefix; + if (!String.IsNullOrWhiteSpace(optionsSaved.WorktreeSubFolder)) + pathPrefix = Path.Combine(_activeRepositoryPath, optionsSaved.WorktreeSubFolder); + else if (!String.IsNullOrEmpty(optionsSaved.DefaultWorktreeDirectory)) + pathPrefix = optionsSaved.DefaultWorktreeDirectory; + else + pathPrefix = worktreePath; string cleanedBranchName = _selectedBranch_Worktree.ToFolderFormat(); await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); From 136bc2c1a240f05c928201fad41f5806fe7c4ad1 Mon Sep 17 00:00:00 2001 From: Marc Czulewicz Date: Fri, 22 May 2026 10:33:26 -0400 Subject: [PATCH 2/2] update docs --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index af5215d..e8f5300 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,12 @@ Accessible via **Git > Settings > Source Control > Git Worktree** * If empty, defaults to: `repo directory\repo_name_worktree\branch_name` * Otherwise, uses your custom directory +* **Worktree Sub-Folder**: + + * Folder name created inside each repository to hold its worktrees (e.g. `.worktrees`) + * Result: `repo directory\\branch_name` + * When set, takes precedence over **Default Worktree Directory** + * Tip: add the folder to `.gitignore` to keep the parent repo clean * **Load**: * If True: opens new worktree in a new window after creation