saif publish fails: Remote 'origin' already exists with different URL¶
One-sentence summary: saif publish tries to add an origin remote without a user prefix, but the repository's existing origin remote still has the old user@ prefixed Azure DevOps URL, so the add fails; update the git remote URL manually to remove the user prefix.
🚨 Symptom¶
saif publish fails while pushing to the remote, with output similar to:
i Publishing application from C:\Users\<user>\dev\<repo-name>
i Repository '<repo-name>' already exists, reusing it
i Pushing to remote...
i git remote add origin https://dev.azure.com/<org>/<project>/_git/<repo-name>
Error: Remote 'origin' already exists with URL 'https://<org>@dev.azure.com/<org>/<project>/_git/<repo-name>'. Cannot add with different URL
'https://dev.azure.com/<org>/<project>/_git/<repo-name>'.
Command completed in 4783ms
📌 Applies to¶
| Aspect | Value |
|---|---|
| Component | saif CLI, saif publish |
| Forge versions | saif CLI 3.8.4 and earlier (fixed in 3.9.0, not yet released) |
| Related versions | Check the version compatibility matrix |
🧠 Cause¶
The local repository's origin remote was set up earlier with an Azure DevOps URL that includes the organization name as a user prefix (https://<org>@dev.azure.com/...). saif publish tries to add origin again using the same URL without that user prefix (https://dev.azure.com/...). Git treats these as different remote URLs and refuses to overwrite the existing one, so the command fails. This is fixed in saif CLI 3.9.0, which has not shipped yet as of this writing.
✅ Fix¶
Until 3.9.0 ships, update the existing origin remote to drop the user@ prefix so it matches what saif publish expects:
-
Check the current remote URL:
-
Update it to remove the
<org>@prefix: -
Re-run
saif publish.
🔬 Verify¶
shows origin without the user@ prefix, and saif publish completes without the "Remote 'origin' already exists with different URL" error.