You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's currently hard to use the telescope worktree creation functionality, because it only works well for branches that have been checked out locally as well. There are a few issues when trying to create a worktree from a tracking branch:
The Git.has_branchlogic will not find the branch (the git branch list does not contain remote tracking branches) and hence a new branch will incorrectly be created here. Fix: check for remote tracking branches as well
The following issue in git-worktree v1 still applies when one tries to create a git worktree from a remote-tracking branch: Additional origin added for Head and Merge ThePrimeagen/git-worktree.nvim#77. To summarize, for the new branch the <remote>/ prefix is kept in the local branch name as well, which results in a rather confusing user experience (e.g. in git log, there's now two references called <origin>/<branch>). Potential fix (related PR: [RFC] Set --track when creating a worktree #20.): git checkout and git worktree add have the same semantics, where if the starting branch is a tracking branch that does not exist locally and is present in a single remote, then a local checkout is created. Therefore, the Telescope git_branches command has faced a similar concern already, where remote branches are shown but usually what the user wants is to checkout a new, local branch (relevant issue: git_branch checkout a non-local remote branch nvim-telescope/telescope.nvim#1932). They have solved this by binding the function git_track_branch (https://github.com/nvim-telescope/telescope.nvim/blob/5972437de807c3bc101565175da66a1aa4f8707a/lua/telescope/actions/init.lua#L748-L756) to <C-T>, allowing one to pass the --track option to git checkout, which provides the correct semantics. The telescope picker for git-worktree could similarly allow passing the --track option to git worktree add.
It's currently hard to use the telescope worktree creation functionality, because it only works well for branches that have been checked out locally as well. There are a few issues when trying to create a worktree from a tracking branch:
Git.has_branchlogic will not find the branch (thegit branchlist does not contain remote tracking branches) and hence a new branch will incorrectly be created here.Fix: check for remote tracking branches as well
git-worktree v1still applies when one tries to create a git worktree from a remote-tracking branch: Additional origin added for Head and Merge ThePrimeagen/git-worktree.nvim#77. To summarize, for the new branch the<remote>/prefix is kept in the local branch name as well, which results in a rather confusing user experience (e.g. ingit log, there's now two references called<origin>/<branch>).Potential fix (related PR: [RFC] Set --track when creating a worktree #20.):
git checkoutandgit worktree addhave the same semantics, where if the starting branch is a tracking branch that does not exist locally and is present in a single remote, then a local checkout is created. Therefore, theTelescope git_branchescommand has faced a similar concern already, where remote branches are shown but usually what the user wants is to checkout a new, local branch (relevant issue: git_branch checkout a non-local remote branch nvim-telescope/telescope.nvim#1932). They have solved this by binding the functiongit_track_branch(https://github.com/nvim-telescope/telescope.nvim/blob/5972437de807c3bc101565175da66a1aa4f8707a/lua/telescope/actions/init.lua#L748-L756) to <C-T>, allowing one to pass the--trackoption togit checkout, which provides the correct semantics. The telescope picker forgit-worktreecould similarly allow passing the--trackoption togit worktree add.is necessary in the default case. This seems to differ from the
git-worktreesemantics one would expect, and seems to cause the "double origin" part of the aforementioned issue (Additional origin added for Head and Merge ThePrimeagen/git-worktree.nvim#77).