Context
While trying out the answer provided in this question on how to check if a GitHub repository exists using bash, I notice that the command asks for credentials and throws an error if the repository is not found:
git ls-remote https://github.com/some_git_user/some_non_existing_repo_name -q
Username for 'https://github.com': some_git_user
Password for 'https://some_git_user@github.com':
remote: Repository not found.
fatal: repository 'https://github.com/some_git_user/some_non_existing_repo_name/' not found
(base) somename@somepcname:~$ echo $?
128
This answer seems to prevent git from asking credentials.
Issues
- Being asked for credentials is fine in other scenarios, so I would prefer to not disable
gitfrom asking credentials system-wide. Yet still, I would like the function to run automatically without asking for credentials, as they are not needed for a check to a public repository. - The command yields an error status 128 if it does not find the repository. Instead, I would like to safely check if the repository is found or not, without raising an error. E.g. by producing outputs
echo "FOUND"orecho "NOTFOUND".
Question
How can one test if a public GitHub repository exists in bash, without being prompted for credentials, without raising an error?
Details
The user has not provided any ssh-key nor credentials to/in the script.