I defined an git alias to achieve just this (before I found this question).
It's a short bash function which saves the current path, switch to the git repo, does a checkout and return where it started.
git checkto develop ~/my_project_git
This e.g. would checkout the develop branch into "~/my_project_git" directory.
This is the alias code inside ~/.gitconfig
:
[alias]
checkTo = "!f(){ [ -z \"$1\" ] && echo \"Need to specify branch.\" && \
exit 1; [ -z \"$2\" ] && echo \"Need to specify target\
dir\" && exit 2; cDir=\"$(pwd)\"; cd \"$2\"; \
git checkout \"$1\"; cd \"$cDir\"; };f"