git-link icon indicating copy to clipboard operation
git-link copied to clipboard

not working for files in an auxiliary worktree (using git-worktree)

Open edgimar opened this issue 4 years ago • 4 comments

Given a git repository contained in the folder foo, if (from this folder) the command git worktree add ../foo-worktree-otherbranch otherbranch is executed, a worktree will be created for the otherbranch branch in the folder ../foo-worktree-otherbranch (relative to the foo folder).

When editing a file within the foo-worktree-otherbranch folder, and attempting to use git-link, the error Remote 'origin' not found occurs. Instead, git-link should be able to correctly identify the remote and branch. In the particular case this was tested under, the foo repository didn't even have an origin remote (but did have other remotes).

edgimar avatar Jul 07 '21 21:07 edgimar

Instead, git-link should be able to correctly identify the remote and branch.

How to do that?

In the particular case this was tested under, the foo repository didn't even have an origin remote (but did have other remotes).

If git-link-default-remote nor git-link.remote are set, some place in the code will default to origin.

sshaw avatar Jul 07 '21 22:07 sshaw

Closing . If the above git-link* options do not work for you feel free to reopen.

sshaw avatar Jul 12 '21 02:07 sshaw

Ok thanks for the information - I believe that the problem has something to do with git-link not being able to determine what the upstream repository and tracked branch is in the case when a "git-worktree" branch is being used. If I have more time to investigate, and find out anything more specific, I'll reopen.

edgimar avatar Jul 14 '21 16:07 edgimar

FWIW, I routinely use git-link with worktrees. It reliably finds the branch I am on. Since my remote is called origin, I would not have observed any issue determining the remote.

bergey avatar Mar 31 '22 12:03 bergey