Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check that git repository exists

Tags:

git

github

Is there any way how to check whether git repository exist just before perform git clone action? Something like git clone $REMOTE_URL --dry-run?

I would like to implement fast checking method which will check existence before the clone action will be performed. I expect that connection might be slow and repository might be big even more than 1GB, so I don't want to rely on time extensive operation due to simple validation. The clone will be performed asynchronously in the background when validation passes.

I found this https://superuser.com/questions/227509/git-ping-check-if-remote-repository-exists but it works from git repository context after initial clone action is done.

Maybe there is some git call which works without git repository context and return "some data" if repository on destination exist or error if doesn't.

like image 284
Jan Stanicek Avatar asked May 28 '14 14:05

Jan Stanicek


People also ask

How do I know if a repository exists github?

You can use ls-remote : $ git ls-remote [email protected]:github/markup.

How check if git exists?

You can check whether Git is installed and what version you are using by opening up a terminal window in Linux or Mac, or a command prompt window in Windows, and typing the following command: git --version.

How do I check my repository status?

You can inspect a Git repository by using the git status command. This command allows you to see which changes have been staged, which haven't, and which files aren't being tracked by Git. You should try and remember that status output does not show you any information regarding the committed project history.

How do I check git connectivity?

Testing your Git connectionThe Git connection test verifies that you've set up the correct Git URL and that the Git host is reachable by Looker. The Git connection test also verifies that you have provided a valid Git deploy key and that the deploy key has write access to your Git repository.


1 Answers

The answer that you linked does what you want it to do.

Try running this in a folder without a repository in it:

git ls-remote https://github.com/git/git 

It should show you the references on the remote, even though you haven't added a local repository with git init or done a git clone.

See more: https://www.kernel.org/pub/software/scm/git/docs/git-ls-remote.html

like image 70
Leigh Avatar answered Sep 20 '22 03:09

Leigh