'Test repo that is in detached head state.'

def test_detached_repo(self):

    repo_dir = self.git_repo_dir
    try:
        os.mkdir(repo_dir)
    except OSError:
        pass
    self.addCleanup(shutil.rmtree, repo_dir)
    git_import.add_repo(self.TEST_REPO, (repo_dir / 'edx4edx_lite'), None)
    subprocess.check_output(['git', 'checkout', 'HEAD~2'], stderr=subprocess.STDOUT, cwd=(repo_dir / 'edx4edx_lite'))
    with self.assertRaises(GitImportErrorCannotPull):
        git_import.add_repo(self.TEST_REPO, (repo_dir / 'edx4edx_lite'), None)
