Skip to content

Deleting a remote branch always fails #353

@adisidev

Description

@adisidev
[1] git branch --delete origin/dev-adi-macOS
error: branch 'origin/dev-adi-macOS' not found.
Did you forget --remote?

From the git log.

There are two possible ways to deal with this I imagine:

  1. Conditionally add --remote when the branch the user is requesting to delete is on one of the remotes

    async function deleteBranch({ repository }: MenuState) {
    const ref = await MagitUtils.chooseRef(repository, 'Delete', false, false, false);
    if (ref) {
    try {
    await gitRun(repository.gitRepository, ['branch', '--delete', ref]);
    } catch (error: any) {
    if (error.gitErrorCode === GitErrorCodes.BranchNotFullyMerged) {
    if (await MagitUtils.confirmAction(`Delete unmerged branch ${ref}?`)) {
    return await gitRun(repository.gitRepository, ['branch', '--delete', '--force', ref]);
    }
    }
    }
    }
    }

  2. Add a new function in remote called "Delete branch on remote"
    Presumably, something like this followed by a git push origin --delete (along with other bookkeeping changes would already suffice).
    develop...adisidev:edamagit:patch-1

@kahole if you are okay with either option, I am happy to try and implement whichever option is easier and send in a PR. Thanks for the lovely tool!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions