My "repo" for things like that is always bash_completion. Ok, "tab tab" is the way bash becomes a productive tool, so, where all that magic stuff come from?
there is a /etc/bash_completion.d/ directory where extensions for bash completion are left. there must be a git file executable, open it and seek for something like get_refs(). If you give it a check you will find that git describe and git for-each-ref are your friends, let's try some examples:
A common repo:
$ cd /your/git/repo; git branch -a
master
blaster
* brunch
lunch
remotes/origin/master
remotes/origin/develop
remotes/github/master
Which is my checked branch?
$ git describe --contains --all HEAD
brunch
What are my remotes?
$ git remote
origin
github
What are the branches on remotes?
$ git for-each-ref --format="%(refname:short)" refs/remotes
origin/master
origin/develop
github/master
What are my local branches?
$ git branch
master
blaster
* brunch
lunch
...a more parseable branches output?
$ git for-each-ref --format="%(refname:short)" refs/heads
master
blaster
brunch
lunch
What about tags?
$ git for-each-ref --format="%(refname:short)" refs/heads refs/remotes refs/tags
master
blaster
brunch
lunch
origin/master
origin/develop
github/master
release-0_1
release-0_2
release-1_0
check the "man pages" for this commands, there's much more inside!.