I'm not sure I understand your use case here, because you can't "check out" a particular folder in a repository. In fact, your checkout
command will result in an error:
$ git checkout -b branch DestinationFolder
fatal: git checkout: updating paths is incompatible with switching branches.
Did you intend to checkout 'dir1' which can not be resolved as commit?
If you want to clone a remote repository and set it to a particular branch in a single step, you can use the -b
flag to the clone
command:
$ git clone -b branch git://git.example.com/myrepository
This will have the side effect of also setting up a remote named origin
pointing at the remote repository.