protected function prepareRepository()
    {
        $config = $this->container['config'];

        $this->builder->clean($config['build.directory']); // clear out everything, including .git metadata

        $workingCopy = $this->git->workingCopy($config['build.directory']);

        $this->doGitInit($workingCopy, $config['deploy.git.url'], $config['deploy.git.branch']); // start again at last commit

        $this->builder->clean($config['build.directory'], true); // clear the old content but keep .git folder

        return $workingCopy;
    }