git remote Command: Manage Remotes in CI
git remote lists, adds, and edits the named remotes a repository tracks.
CI often clones read-only and then needs to push, so a common pattern is to rewrite the origin URL to include a token. git remote is how you inspect and change those URLs.
Common flags
-v- list remotes with their fetch and push URLsadd <name> <url>- add a new remoteset-url <name> <url>- change the URL of a remoteset-url --push <name> <url>- set a separate push URLremove <name>- delete a remoteget-url <name>- print the URL of a remote
Example
shell
# Re-point origin at a tokenized URL so CI can push
git remote set-url origin \
"https://x-access-token:${GITHUB_TOKEN}@github.com/owner/repo.git"
git remote -vIn CI
Rewriting origin with set-url to embed a token is the simplest way to enable pushes after a read-only checkout. Use --push to keep fetch and push URLs separate when the runner pulls anonymously but pushes authenticated.
Key takeaways
- git remote set-url rewrites origin to a tokenized URL so CI can push.
- -v reveals the exact fetch and push URLs a job is using.
- --push sets a push-only URL when fetch and push need different auth.
Related guides
git push Command: Publish Refs in CIgit push uploads commits and tags to a remote. Reference for --tags, --follow-tags, and --force-with-lease as…
git config Command: Configure Git in CIgit config reads and writes Git settings. Reference for user.email, --global, and credential.helper to set up…
git clone Command: Clone Repos in CIgit clone copies a remote repository into a new directory. Reference for --depth, --branch, --filter, and --r…
git ls-remote Command: Query Remote Refs in CIgit ls-remote lists refs on a remote without cloning. Reference for --tags, --heads, and resolving a branch S…