Skip to content

Suggest a path when creating worktrees #5664

@diegovilar

Description

@diegovilar

Is your feature request related to a problem? Please describe.

When creating a worktree for a branch, lazygit presents a popup with an empty input field for the user to provide the path the new worktree should be created in. This can be error-prone, easily allowing the user to inadvertently create worktrees with different base paths.

Describe the solution you'd like

As far as UX goes, it would be really nice if lazygit could suggest the path based on the branch name, preferably with a common base path related to the original clone directory. It would save a lot of typing and, more importantly, allow for fewer mistakes.

Examples:

  • /home/dev/projects/my-project.worktrees/features-add-disclaimer
  • /home/dev/projects/my-project.worktrees/upgrade-git

Aditional context

Tools like VSCode and GitGraken suggest a sibling directory to the clone being worked on, with a ".worktrees" suffix, as the base path for all worktrees related to that clone. They also suggest a directory name for the new worktree itself, based on the branch name. Tools diverge on the suggested name, but the base path is consistent.

As an example, for a repository cloned at /home/dev/projects/my-project, when creating a worktree for the features/add-disclaimer branch, these paths will be suggested to the user:

  • VSCode: /home/dev/projects/my-project.worktrees/features-add-disclaimer (if checked out)
  • VSCode: /home/dev/projects/my-project.worktrees/<remote-name>/features-add-disclaimer (if not yet checked out)
  • GitKraken: /home/dev/projects/my-project.worktrees/features/add-disclaimer (does not slugify and does not care whether it has already been checkedout or not)

Other tools, like InteliJ IDEA, do not suggest a base path, creating the worktrees directly as siblings to the clone (i.e.: /home/dev/projects/features-add-disclaimer). I do prefer the idea of a base path for worktrees, as it keep thinks contextualized (a standalone feature branch-named directory on my projects directory can be confusing).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions