While running git branch -a , I am getting out put like the below
git branch -a
* development
remotes/origin/AWS-MIGRATION
remotes/origin/HEAD -> origin/development
remotes/origin/RMR-2809
I want to remove the remotes/origin/HEAD -> origin/development
I want to see only pure branch names.
CodePudding user response:
Run:
git remote set-head origin --delete
This will delete the refs/remotes/origin/HEAD
name; git branch -r
shortens it to origin/HEAD
and git branch -a
shortens in to remotes/origin/HEAD
, so this is the name you want to get rid of.
Note that this name may come back, or not, depending on various other operations you run (including another git remote set-head
). The remotes/origin/*
names you see here are not really branch names, but rather remote-tracking names. Git calls these remote-tracking branch names and shows them under -r
or -a
output, but not under git branch
output.
(In my opinion, there's no really good reason to delete the name, but there's no particularly good reason to keep it either.)
If you're writing programs that deal with branch names, do not use git branch
to generate the list of names: this is the wrong tool. (It's what Git calls porcelain, i.e., a tool mean to produce output read by a human. Git's plumbing tools produce output meant to be read by other programs.)