Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion GitWorkTree/Options/General.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class GeneralOptions : BaseOptionPage<General>
{
public bool IsLoadSolution { get; set; }
public string DefaultWorktreeDirectory { get; set; }
public string WorktreeSubFolder { get; set; }
}
}

Expand All @@ -22,8 +23,13 @@ public class General : BaseOptionModel<General>


[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 \"<repo>_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; }
}
}
8 changes: 7 additions & 1 deletion GitWorkTree/ViewModel/WorkTreeDialogViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,13 @@ private async Task<bool> 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();
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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\<sub-folder>\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
Expand Down