Skip to content

Delete remote branch #671

Closed
Closed
@noff

Description

@noff

I'm trying to clone repo and then delete one of the remote branches.

When I delete local version of the branch, it works:

 repo.branches.each do |x|
      if x.name == repo_branch_to_delete
        x.delete
      end
    end

But I can't push changes:

repo.push 'origin'
Traceback (most recent call last):
        2: from (irb):124
        1: from (irb):125:in `rescue in irb_binding'
Git::FailedError (git '--git-dir=/***/repos/431/.git' '--work-tree=/***/repos/431' '-c' 'core.quotePath=true' '-c' 'color.ui=false' 'push' 'origin'  2>&1)
status: pid 42218 exit 128
output: "fatal: The current branch bot_431 has no upstream branch.\nTo push the current branch and set the remote as upstream, use\n\n    git push --set-upstream origin bot_431\n\nTo have this happen automatically for branches without a tracking\nupstream, see 'push.autoSetupRemote' in 'git help config'.\n\n"

The question is: what is the correct way to delete remote+local branches?

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions