Use git branch -m
to rename your branch:
git branch -m oldname newname
Edit: per question-edit, it seems that you had a branch named X (for some X) and a tag also named X (for some X). In this particular case, some operations resolve the name to the branch name, and some to the tag name.
Deleting one of the names works, of course. But you can also disambiguate the names. A branch or tag name is a bit like someone's given name. If you have two guys named Bruce, you can refer to them as Bruce Arthur Robertson and Bruce Leonard Sadler, and now everyone knows which Bruce you mean—and similarly, you can refer to refs/head/X
to refer to branch X, and refs/tags/X
to refer to tag X. You can leave out the refs/
part, using heads/X
and tags/X
, as well.
Since tag names are usually intended as global (shared across all clones, and everyone's v1.2
will refer to the exact same commit) while branch names are usually intended as local (your debug2
commit is probably different from Fred's debug2
commit), it's generally wise to name tags carefully, and then never change or delete them; branch names are more ephemeral and easier to change and delete. But these aren't hard-and-fast rules, so do whatever is appropriate for your situation.