Question:
I want to delete a branch both locally and remotely from a GitHub project.
Locally deleted
> git branch -D feature/experiment
> Deleted branch feature/experiment (was 863225e).
Attempts to delete a branch on the server
> git branch -d origin/feature/experiment
error: branch 'origin/feature/experiment' not found.
> git branch -rd origin/feature/experiment
Deleted remote branch origin/feature/experiment (was 863225e).
> git pull
* [new branch] feature/experiment -> origin/feature/experiment
It's not clear what "Deleted remote branch" means if the branch was not actually deleted? The subsequent pull
command shows this.
What should I do to delete a branch both locally and on the server?
Answer:
In Git v1.7.0, you can delete a remote branch using
git push origin --delete <branchName>
which is easier to remember than
git push origin :<branchName>
added in Git v1.5.0 "to remove a remote branch or tag".