After I clone a git repository locally, I want to switch branch to, says, 'ABCD'.

$ git branch -a
* master
remotes/origin/ABCD
remotes/origin/HEAD -> origin/master
remotes/origin/master
$ git checkout origin/ABCD #### <- Here is the problem!
Note: checking out 'origin/ABCD'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b new_branch_name
HEAD is now at f2bf54a... Clean up README.md

When I press tab after git checkout, for some reason the autocompletion always starts with origin/ and hence a warning message of detached HEAD state.

I don't see a completion issue here: you don't have a local branch ABCD, so it's normal for zsh to offer only master and origin/… as completions. Why did you expect other completions? To create a local branch, run git checkout -t origin/ABCD or git branch -t ABCD origin/ABCD.
– GillesMar 2 '15 at 3:25

If I switch to bash and tried git checkout <TAB> I will see ABCD instead even though ABCD is not a no local branch. I think it is a behavioural difference.
– Anthony KongMar 2 '15 at 3:32

Did you find a solution? This annoys me too and means I need to either manually type the branch or go back and delete the origin part. Are we doing it the wrong way?
– AstaMay 12 '15 at 13:16