Git でもっと簡単にリモートブランチを Checkout したい

Git で特定のリモートブランチ (を追跡するローカルブランチ) を checkout してくるためには以下のような -b オプションを付けた git-checkout コマンドを使うと思っていました。

git checkout -b features/hoge origin/features/hoge

しかしこれでは features/hoge を何度も入力しなくてはいけませんし、とてもめんどくさいのです。というわけで man git-checkout を眺めていたら --track (-t) というオプションを見つけました。

-t, --track
       When creating a new branch, set up "upstream" configuration. See "--track" in git-branch(1) for details.

       If no -b option is given, the name of the new branch will be derived from the remote-tracking branch. If "remotes/" or "refs/remotes/" is prefixed it is stripped away, and then the
       part up to the next slash (which would be the nickname of the remote) is removed. This would tell us to use "hack" as the local branch when branching off of "origin/hack" (or
       "remotes/origin/hack", or even "refs/remotes/origin/hack"). If the given name has no slash, or the above guessing results in an empty name, the guessing is aborted. You can
       explicitly give a name with -b in such a case.

なるほどこれは便利そうですね。

というわけで以下のようなコマンドでリモートブランチを手軽に checkoutできるようになります。

git checkout -t origin/features/hoge

便利ですね!ついでに checkout を co とかに alias しておくとさらに良いと思われます。