Skip to content
Open
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
12 changes: 9 additions & 3 deletions lua/git-worktree/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,15 @@ local function create_worktree_job(path, branch, found_branch)
local worktree_add_args = {'worktree', 'add'}

if not found_branch then
table.insert(worktree_add_args, '-b')
table.insert(worktree_add_args, branch)
table.insert(worktree_add_args, path)
if branch:find('^origin/') then
table.insert(worktree_add_args, path)
local local_branch_name = branch:gsub("origin/", "")
table.insert(worktree_add_args, local_branch_name)
else
table.insert(worktree_add_args, '-b')
table.insert(worktree_add_args, branch)
table.insert(worktree_add_args, path)
end
else
table.insert(worktree_add_args, path)
table.insert(worktree_add_args, branch)
Expand Down