Delete a specific remote branch (note, we need the name of the ‘remote’)
git branch -r -d origin/BRANCH_NAME
Remove a branch from a remote named foo
# Prune all the local branches tracking deleted remote branches on the remote 'foo'# I.e.:# local branch: Exist# remote branch: Delete# remote name: foogit fetch --prune foo# If the branch has already been removed in the `remote`, like github, you can:# I.e. prune local branches for all remotes.git fetch --all --prune
If the remote_branch_name does not match with the local_branch_name:
git push will not work automatically. It will complain there is no simple match between local branch and remote branch. In this case:
git push <remote_name> <remote_branch_name># But non-master -> 'master' case, is an exception.# For 'master', 'HEAD' is requiredgit push <remote_name> HEAD:master
After using git init on a local directory, there is no ‘default’ remote added for that git directory (of course, since the git directory is not cloned from a remote). You need to manually add the ‘remotes’ for it.