Disambiguation: master
on origin
vs origin/master
on your local repo
You didn't make it very clear in your question about what you mean by whether or not you should delete your remote master branch, because in reality, you could be referring to two different but related branches:
master
on the remote origin
This is the master
branch on your remote origin. If you wanted to delete it, you could do
git push origin --delete master
# Or
git push origin :master
However, in typical Git workflows, Git users want to keep that branch around for various reasons, including (but not limited to):
- Sharing work on the
master
branch with other people.
- Keeping a backup of the work done to the
master
branch.
Given that, there's usually not a good reason to delete this branch on the remote, even if you're working alone.
Remote-tracking branch origin/master
on your local repo
This is the remote-tracking branch on your local repo that keeps track of the state of the master
branch on the remote origin
. To delete remote-tracking branches, you need to use the --remotes
or -r
flag (as it states in the documentation for git branch
):
git branch --remotes --delete origin/master
As the documentation for git branch
states:
-r
--remotes
List or delete (if used with -d
) the remote-tracking branches.
However, deleting your remote-tracking branch for master is not usually a good idea in most cases, because it helps you to keep track of changes to the remote master branch.
As meager point's out, you don't normally delete remote-tracking branches until you're actually done using the branch that the remote-tracking branch tracks. A typical case if if you have a remote feature
branch that you're done with, you delete it from the remote:
git push origin --delete feature
and then update your local repository references to "prune" the obsolete remote-tracking branch:
git fetch origin --prune
# Or shorter
git fetch origin -p
However, in the case of the master
branch, you're never really "done" with that branch, because for most Git workflows, it represents the main, canonical line of development and history.
Please Read
To learn more about working with remote branches please read