tuio0w
Last Updated: February 25, 2016
·
3.305K
· mlafeldt
2190d7a468f51fa3be5eabfc9397a28b

Check that a remote Git repo or ref exists

I've recently configured a build job in Jenkins that clones source code from GitHub. I accidentally entered an invalid Git repository URL and this is what Jenkins yelled at me:

Failed to connect to repository : Command "git ls-remote -h git@github.com:USER/REPO.git HEAD" returned status code 128:
stdout:
stderr: ERROR: Repository not found.
fatal: The remote end hung up unexpectedly

Through this error I learned about git ls-remote and how it can be used to

  • list references in a remote repository
  • check that a repository exists at all
  • check that a specific ref exists (use --exit-code)

All that without cloning the repository in question.

Say Thanks
Respond
Filed Under