-
-
Notifications
You must be signed in to change notification settings - Fork 108
-
Hello, is there a way to get the getRemoteBranches from a remote repo without cloning it locally?
$git = new \CzProject\GitPhp\Git;
$repo = $git->open('https://github.com/czproject/git-php.git');
var_dump($repo->getRemoteBranches());
But this return :
"Repository 'https://github.com/czproject/git-php.git' not found.",
"file": "/var/www/vendor/czproject/git-php/src/GitRepository.php",
"line": 28,
Any help would be appreciated!
Beta Was this translation helpful? Give feedback.
All reactions
Hello!
I see two options:
1) Use empty local repository
$git = new CzProject\GitPhp\Git; $repo = $git->init(__DIR__ . '/empty-repo'); $repo->addRemote('origin', 'https://github.com/czproject/git-php'); var_dump($repo->execute('ls-remote', '--heads', 'origin'));
2) Use CliRunner directly and run command ls-remote manually
$runner = new CzProject\GitPhp\Runners\CliRunner; var_dump($runner->run(__DIR__, ['ls-remote', '--heads', 'https://github.com/czproject/git-php'])->getOutput());
Replies: 1 comment 2 replies
-
Hello!
I see two options:
1) Use empty local repository
$git = new CzProject\GitPhp\Git; $repo = $git->init(__DIR__ . '/empty-repo'); $repo->addRemote('origin', 'https://github.com/czproject/git-php'); var_dump($repo->execute('ls-remote', '--heads', 'origin'));
2) Use CliRunner directly and run command ls-remote manually
$runner = new CzProject\GitPhp\Runners\CliRunner; var_dump($runner->run(__DIR__, ['ls-remote', '--heads', 'https://github.com/czproject/git-php'])->getOutput());
Beta Was this translation helpful? Give feedback.
All reactions
-
@janpecha thank you for your answer, really appreciate your help.
Any idea why when I change the remote to ssh like this :
$runner = new CzProject\GitPhp\Runners\CliRunner;
var_dump($runner->run(__DIR__, ['ls-remote', '--heads', ' "git@github.com:czproject/git-php.git"])->getOutput());
I got this error message"Host key verification failed. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.", ! Cheers!
Beta Was this translation helpful? Give feedback.
All reactions
-
I don't know why, if I changed repository address, it worked too:
$runner = new CzProject\GitPhp\Runners\CliRunner; var_dump($runner->run(__DIR__, ['ls-remote', '--heads', "git@github.com:nette/utils.git"]));
Beta Was this translation helpful? Give feedback.