Skip to content

Allow upstream push to a branch with a different name #1758

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
13 changes: 10 additions & 3 deletions lua/neogit/popups/push/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ local function push_to(args, remote, branch, opts)
logger.debug("Pushing to " .. name)
notification.info("Pushing to " .. name)

local current_branch = git.branch.current()
if branch and current_branch ~= branch then
branch = current_branch .. ":" .. branch
end
local res = git.push.push_interactive(remote, branch, args)

-- Inform the user about missing permissions
Expand Down Expand Up @@ -83,9 +87,12 @@ function M.to_upstream(popup)
remote, branch = git.branch.parse_remote_branch(upstream)
else
set_upstream = true
branch = git.branch.current()
remote = git.branch.upstream_remote()
or FuzzyFinderBuffer.new(git.remote.list()):open_async { prompt_prefix = "remote" }
local target = FuzzyFinderBuffer.new(git.refs.list_remote_branches()):open_async {
prompt_prefix = "push",
}
if target then
remote, branch = git.branch.parse_remote_branch(target)
end
end

if remote then
Expand Down
Loading