{"record":{"id":"a33414796a32f0e9","repo":"jesseduffield/lazygit","slug":"cannot-fast-forward-a-branch-whose-remote-is-not-r","errorCode":null,"errorMessage":"Cannot fast-forward a branch whose remote is not registered locally","messagePattern":"Cannot fast-forward a branch whose remote is not registered locally","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/gui/controllers/branches_controller.go","lineNumber":663,"sourceCode":"\t\tItems: []*types.MenuItem{localDeleteItem, remoteDeleteItem, deleteBothItem},\n\t})\n}\n\nfunc (self *BranchesController) merge() error {\n\tselectedBranchName := self.context().GetSelected().Name\n\treturn self.c.Helpers().MergeAndRebase.MergeRefIntoCheckedOutBranch(selectedBranchName)\n}\n\nfunc (self *BranchesController) rebase(branch *models.Branch) error {\n\treturn self.c.Helpers().MergeAndRebase.RebaseOntoRef(branch.Name)\n}\n\nfunc (self *BranchesController) fastForward(branch *models.Branch) error {\n\tif !branch.IsTrackingRemote() {\n\t\treturn errors.New(self.c.Tr.FwdNoUpstream)\n\t}\n\tif !branch.RemoteBranchStoredLocally() {\n\t\treturn errors.New(self.c.Tr.FwdNoLocalUpstream)\n\t}\n\tif branch.IsAheadForPull() {\n\t\treturn errors.New(self.c.Tr.FwdCommitsToPush)\n\t}\n\n\taction := self.c.Tr.Actions.FastForwardBranch\n\tworktree, ok := self.worktreeForBranch(branch)\n\n\treturn self.c.WithInlineStatus(branch, types.ItemOperationFastForwarding, context.LOCAL_BRANCHES_CONTEXT_KEY, func(task gocui.Task) error {\n\t\tif ok {\n\t\t\tself.c.LogAction(action)\n\n\t\t\tworktreeGitDir := \"\"\n\t\t\tworktreePath := \"\"\n\t\t\t// if it is the current worktree path, no need to specify the path\n\t\t\tif !worktree.IsCurrent {\n\t\t\t\tworktreeGitDir = worktree.GitDir\n\t\t\t\tworktreePath = worktree.Path","sourceCodeStart":645,"sourceCodeEnd":681,"githubUrl":"https://github.com/jesseduffield/lazygit/blob/c477a2959b229fbf3284be0d4d2904ab61ec3c94/pkg/gui/controllers/branches_controller.go#L645-L681","documentation":"Thrown by BranchesController.fastForward when the selected branch tracks an upstream whose remote-tracking ref does not exist in the local repository (RemoteBranchStoredLocally() is false). lazygit fast-forwards by merging from the locally stored remote branch (e.g. origin/foo), so it refuses when that ref is missing even though upstream is configured. It is a precondition guard, not a git failure.","triggerScenarios":"Pressing the fast-forward key ('f') on a branch where branch.IsTrackingRemote() is true but refs/remotes/<remote>/<upstream> is absent from the local refs. Typical after a shallow/partial clone, after 'git remote prune' removed stale remote refs, or when the upstream was set with 'git branch --set-upstream-to' but never fetched.","commonSituations":"Fresh clones with limited refspecs, repositories where the remote was renamed (upstream points at old remote name), or CI checkouts with --single-branch so other remote branches were never fetched.","solutions":["Run 'git fetch <remote>' (or press 'f' in the branches panel after fetching) so refs/remotes/<remote>/<branch> exists locally","Verify the upstream configuration with 'git branch -vv' and the remote ref with 'git branch -r | grep <branch>'","If the remote was renamed, update the upstream: 'git branch --set-upstream-to=<new-remote>/<branch>'","If you actually have local commits to integrate, use rebase or merge instead of fast-forward"],"exampleFix":"# before\ngit branch --set-upstream-to=origin/feature feature   # upstream set, but ref never fetched; 'f' errors\n# after\ngit fetch origin\ngit branch --set-upstream-to=origin/feature feature","handlingStrategy":"validation","validationCode":"// Before invoking fast-forward, ensure the remote-tracking ref exists locally:\n// (Go, mirroring the model checks in branches_controller.go)\nfunc canFastForward(branch *models.Branch, remotes []*models.Remote) error {\n\tif !branch.IsTrackingRemote() {\n\t\treturn fmt.Errorf(\"branch %s has no upstream\", branch.Name)\n\t}\n\tif !branch.RemoteBranchStoredLocally() {\n\t\treturn fmt.Errorf(\"run 'git fetch %s' first: remote branch not stored locally\", branch.RemoteName())\n\t}\n\tif branch.IsAheadForPull() {\n\t\treturn fmt.Errorf(\"branch %s is ahead of upstream; push or pull first\", branch.Name)\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Fetch the remote before attempting fast-forward actions","Always create branches from remote refs or push with -u so remote-tracking refs exist","Check 'git branch -vv' for '[origin/...]' upstream markers before automating fast-forwards"],"tags":["git","fast-forward","upstream","remote-refs"],"backgroundTag":null,"analyzedSha":"c477a2959b229fbf3284be0d4d2904ab61ec3c94","analyzedAt":"2026-08-15T08:34:32.451Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}