Home > Blockchain >  How to delete a remote branch?
How to delete a remote branch?

Time:10-27

In my GitHub, I have successfully merged my pull request and deleted the branch sec1. Then, I delete my branch locally. However, when I type git branch -a, I still can see the remotes/origin/sec1 branch, like shown below

* main
  remotes/origin/HEAD -> origin/main
  remotes/origin/main
  remotes/origin/sec1

Then, I try git push origin --delete sec1 but it gives me this error:

error: failed to push some refs to https:/.../

Anyone can help with this?

CodePudding user response:

Remotely try this:

  git push -d origin <Branch-Name>

Locally:

git branch -D <Branch-Name>

CodePudding user response:

Run first git fetch, to retrive the latest meta-data info from the original (remote). And then execute git branch --delete sec1.

If this not work, you can need the force-option (-D is the shortcut for --delete and --force):

git branch -D sec1
  • Related