Deleting a remote branch from a GitHub account is easy though I have seen numerous ways listed and only one of them worked for me possibly because of syntax errors. Sometimes a temporary branch may be necessary because of adding a contractor to work on a project or possibly just to pause the current projects to get something pushed out quickly.
Use the syntax below to remove a branch from GitHub.com.
- git push email@example.com:ACCOUNT/SPACE.git :heads/BRANCH
Replace ACCOUNT, SPACE, and BRANCH with the details for your scenario. Once you issue this command you should see output like the below confirming the account was deleted.
- [user@dev project]$ git push firstname.lastname@example.org:github-account/github-space.git :heads/18.104.22.168-rc
- To email@example.com:github-account/github-space.git
- - [deleted] 22.214.171.124-rc
The other possibility to remove a remote branch on GitHub is using the below syntax.
- git push origin :branch
Again I attempted to use the shorter version though it did not work for me so I wanted to list both options with the notes about the longer version working and the shorter one not working.