public function exists($username, $repository, $path, $reference = null)
    {
        $url = '/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/contents';

        if (null !== $path) {
            $url .= '/'.rawurlencode($path);
        }

        try {
            $response = $this->head($url, [
                'ref' => $reference,
            ]);

            if ($response->getStatusCode() !== 200) {
                return false;
            }
        } catch (TwoFactorAuthenticationRequiredException $ex) {
            throw $ex;
        } catch (\Exception $ex) {
            return false;
        }

        return true;
    }