All packages
Git for Laravel
Clone URLs
repo($path)->cloneUrl() builds an authenticated HTTPS clone URL for deploy and CI steps — no manual URL assembly:
use RoundlyConsulting\Git\Dto\Credentials\Token;
$url = Git::github()->repo('acme/api')->cloneUrl('acme', Token::from('ghp_...'));
// https://token:[email protected]/acme/api.gitTo clone with the credential the package itself is configured with, read it off the facade:
use RoundlyConsulting\Git\Enums\ProviderName;
$credentials = Git::credentials(ProviderName::Github); // ?Credentials — app installation, else token, else null
$url = Git::github()->repo('acme/api')->cloneUrl('acme', $credentials);A refreshable credential is asked for a live token instead of being read for a static one, and an installation token gets GitHub’s documented username:
$url = Git::github()->repo('acme/api')->cloneUrl('acme', $installationCredentials);
// https://x-access-token:[email protected]/acme/api.gitPer provider
| Provider | Username in the URL | Host |
|---|---|---|
| GitHub | x-access-token for a GithubAppToken, token for any other credential | The web host derived from the API URL — a leading api. label dropped, or a trailing /api/v3 on Enterprise Server |
| GitLab | oauth2 | The configured GitLab URL |
| Bitbucket | The $username you pass | The web host derived from the API URL — a leading api. label dropped |
Worth knowing
- For an installation credential this is a network call — it mints a token or reads a cached one — so a loop over N repositories is N mints on a cold cache.
- A GithubApp credential is refused: the app’s own JWT can mint a token for every installation of the app, and a clone URL ends up in git remote and in process environments.
- The username and secret are percent-encoded, so a credential containing @, / or : still yields a URL whose host is the forge ([email protected] / p@ss → https://me%40acme.io:p%40ss@…).
- Scope the installation token to the repository you clone — see Scoped tokens & installations.
Show your open-source love
This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.
More ways to support, including cryptoBy donating, you agree to our donation terms.
Want this built into your product?
We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.