Skip to content

Delete remote branch #671

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

Closed
noff opened this issue Oct 2, 2023 · 1 comment · Fixed by #672
Closed

Delete remote branch #671

noff opened this issue Oct 2, 2023 · 1 comment · Fixed by #672

Comments

@noff
Copy link

noff commented Oct 2, 2023

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.

@noff
Copy link
Author

noff commented Oct 2, 2023

I found:

repo.push 'origin', branch_name, force: true, delete: true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant