{"record":{"id":"22d7eed6c234b055","repo":"jesseduffield/lazygit","slug":"unsupported-or-invalid-remote-url-s","errorCode":null,"errorMessage":"unsupported or invalid remote URL: %s","messagePattern":"unsupported or invalid remote URL: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/gui/controllers/remotes_controller.go","lineNumber":241,"sourceCode":"// 1. SCP-like SSH: git@host:owner[/subgroups]/repo(.git)\n// 2. SSH URL style: ssh://user@host[:port]/owner[/subgroups]/repo(.git)\n// 3. HTTPS: https://host/owner[/subgroups]/repo(.git)\n// 4. Only for integration tests: ../repo_name\nvar (\n\turlRegex                = regexp.MustCompile(`^(git@[^:]+:|ssh://[^/]+/|https?://[^/]+/)([^/]+(?:/[^/]+)*)/([^/]+?)(\\.git)?$`)\n\tintegrationTestUrlRegex = regexp.MustCompile(`^\\.\\./.+$`)\n)\n\n// Rewrites a Git remote URL to use the given fork username,\n// keeping the repo name and host intact. Supports SCP-like SSH, SSH URL style, and HTTPS.\nfunc replaceForkUsername(originUrl, forkUsername string, isIntegrationTest bool) (string, error) {\n\tif urlRegex.MatchString(originUrl) {\n\t\treturn urlRegex.ReplaceAllString(originUrl, \"${1}\"+forkUsername+\"/$3$4\"), nil\n\t} else if isIntegrationTest && integrationTestUrlRegex.MatchString(originUrl) {\n\t\treturn \"../\" + forkUsername, nil\n\t}\n\n\treturn \"\", fmt.Errorf(\"unsupported or invalid remote URL: %s\", originUrl)\n}\n\nfunc (self *RemotesController) getOrigin() *models.Remote {\n\tfor _, remote := range self.c.Model().Remotes {\n\t\tif remote.Name == \"origin\" {\n\t\t\treturn remote\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc (self *RemotesController) hasOriginRemote() func() *types.DisabledReason {\n\treturn func() *types.DisabledReason {\n\t\tif self.getOrigin() == nil {\n\t\t\treturn &types.DisabledReason{Text: self.c.Tr.NoOriginRemote}\n\t\t}\n\n\t\treturn nil","sourceCodeStart":223,"sourceCodeEnd":259,"githubUrl":"https://github.com/jesseduffield/lazygit/blob/c477a2959b229fbf3284be0d4d2904ab61ec3c94/pkg/gui/controllers/remotes_controller.go#L223-L259","documentation":"replaceForkUsername in pkg/gui/controllers/remotes_controller.go rewrites the origin URL when creating a fork remote in-place. It supports three forms: the generic urlRegex (HTTPS, SSH-user@host:path, ssh:// URLs), and — only in integration tests — a relative ../user URL. Any other format falls through to 'unsupported or invalid remote URL'. Note ../user URLs are intentionally never valid in normal use.","triggerScenarios":"Pressing 'f' (fork) on a remote whose URL matches neither the supported HTTPS nor SSH patterns — e.g. a git:// URL, a local filesystem path like /srv/git/repo.git (not under test mode), or a malformed remote URL with no host.","commonSituations":"Repos cloned from local mirrors or bundled paths; exotic transports (git://, rsync://); remotes added by tooling with unconventional URL spellings; attempting fork on a self-hosted setup whose URL has an unusual scheme.","solutions":["Re-add the remote with a supported URL form: https://host/owner/repo.git or git@host:owner/repo.git / ssh://git@host/owner/repo.git.","Verify with `git remote -v` that the URL is well-formed (has a host and owner/repo path).","If you cannot change the URL, create the fork remote manually (git remote add) instead of using lazygit's fork action."],"exampleFix":"# terminal\n# before\ngit remote set-url origin git://example.com/me/repo.git\n\n# after\ngit remote set-url origin git@example.com:me/repo.git","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"var supportedRemoteURL = regexp.MustCompile(`^(https?://|git@[^:]+:|ssh://)[^/]+/[^/]+/.+$`)\n\nfunc isForkableURL(u string) bool {\n\treturn supportedRemoteURL.MatchString(u)\n}","tryCatchPattern":null,"preventionTips":["Clone via HTTPS or standard SSH URLs so the fork action can rewrite the owner.","Check `git remote -v` before using fork-related actions.","For local-path remotes, add fork remotes manually."],"tags":["git","remotes","fork","url"],"backgroundTag":null,"analyzedSha":"c477a2959b229fbf3284be0d4d2904ab61ec3c94","analyzedAt":"2026-08-15T08:34:32.451Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}