This facility is being done by what's called Bash Completion. The files that back this are stored under /etc//etc/bash_completion.d with each command having its own file. So in the git case:
/etc/bash_completion.d/git
If you look at this file you'll notice that it's overloading your environment with extra functions. One in particular is this guy:
$ __git_commands
When you run it you'll get the list of sub-commands.
$ __git_commands | head -5
add merge-recursive
add--interactive merge-resolve
am merge-subtree
annotate merge-tree
apply mergetool
Knowing that these are simply functions in your environment you can do this:
$ __git<tab><tab>
__git_aliased_command __git_complete_remote_or_refspec __git_diff_index_files __git_index_files __git_refs
__git_aliases __git_complete_revlist __git_diff_index_helper __gitk_main __git_refs2
__git_commands __git_complete_revlist_file __gitdir __git_list_all_commands __git_refs_remotes
__gitcomp __git_complete_strategy __git_find_on_cmdline __git_list_merge_strategies __git_remotes
__gitcompadd __gitcomp_nl __git_func_wrap __git_list_porcelain_commands __git_tags
__gitcomp_file __git_compute_all_commands __git_has_doubledash __git_ls_files_helper __git_wrap__gitk_main
__git_complete __git_compute_merge_strategies __git_heads __git_main __git_wrap__git_main
__git_complete_diff_index_file __git_compute_porcelain_commands __git_index_file_list_filter __git_match_ctag
__git_complete_file __git_config_get_set_variables __git_index_file_list_filter_bash __git_pretty_aliases
__git_complete_index_file __git_count_arguments __git_index_file_list_filter_compat __git_reassemble_comp_words_by_ref
To get a list of all the Bash Completion functions which give various info about git the command.