The following change in the code given below can answer your question:-
$ git push -d <remote_name> <branchname>
$ git branch -d <branchname>
However, one must keep in mind that the <remote_name> will be the origin, in most of the cases.
To eliminate from the local branch, the following code can be used:-
$ git branch -d <branch_name>
$ git branch -D <branch_name>
The -d option is another word or substitute for --delete, which only deletes the branch if it has already been fully integrated into its upstream branch.
The -D option is another word or substitute for --delete --force, which deletes the branch regardless of its merged status on the system.
According to the Git v2.3 version, the git branch -d (delete) learned to honor the -f (force) flag. An error will occur once a user tries to delete the selected branch.
However, according to the Git v1.7.0 version, you can delete a remote branch using
$ git push <remote_name> --delete <branch_name>
which might be easier to memorize than
$ git push <remote_name> :<branch_name>
This was added in Git v1.5.0 "to delete a remote branch or a tag."
In Git v2.8.0, one can also use git push with the -d option as an alias for --delete. Therefore, the version of Git you have installed will decide whether you need to use the easier or harder syntax, respectively.