public function checkout($dest = null)
    {
        $temporary = $this->isTemporary;

        if (true === is_null($dest)) {
            $realdest = $this->cwd;
        } else {
            $realdest = $dest;
        }

        $head = $this->getHead();
        $branch = $head->getName();

        $this->dispatch(VcsEvents::PRE_CHECKOUT, new CheckoutEventData($head, $realdest));

        if (false === $this->hasClone || false === is_null($dest)) {
            $this->cloneRepository($dest);
        } else {
            $this->fetch();

            $result = $this->execute('checkout', array((string) $branch));
        }

        $this->hasCheckout = true;

        $result = $this->pull('origin', $branch);

        $this->dispatch(VcsEvents::POST_CHECKOUT, new CheckoutEventData($head, $realdest));
    }