{"record":{"id":"87fd2b71083c1b57","repo":"jesseduffield/lazygit","slug":"cannot-fast-forward-a-branch-with-no-upstream","errorCode":null,"errorMessage":"Cannot fast-forward a branch with no upstream","messagePattern":"Cannot fast-forward a branch with no upstream","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/gui/controllers/branches_controller.go","lineNumber":660,"sourceCode":"\n\treturn self.c.Menu(types.CreateMenuOptions{\n\t\tTitle: menuTitle,\n\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","sourceCodeStart":642,"sourceCodeEnd":678,"githubUrl":"https://github.com/jesseduffield/lazygit/blob/c477a2959b229fbf3284be0d4d2904ab61ec3c94/pkg/gui/controllers/branches_controller.go#L642-L678","documentation":"Returned by BranchesController.fastForward (branches_controller.go:660) via Tr.FwdNoUpstream. Fast-forwarding means moving a local branch to its upstream's tip; without tracking config (IsTrackingRemote() false) there is no upstream to pull from, so the operation is rejected before the WithInlineStatus task starts. Sibling guards cover the related cases: no locally stored remote ref (FwdNoLocalUpstream) and commits already ahead (FwdCommitsToPush).","triggerScenarios":"Pressing 'f' (fast-forward) on a branch in the local branches panel that has no upstream configured — typically a newly created local branch.","commonSituations":"Branches created locally and not yet pushed; upstream lost after a remote refactor; fresh clones with partial refspecs where un-checked-out branches have no tracking.","solutions":["Push with upstream tracking: 'git push -u origin <branch>', after which fast-forward becomes meaningful (or is unnecessary)","Set the upstream to an existing remote branch: 'git branch --set-upstream-to=origin/<branch> <branch>'","If you meant to update from another branch, use merge (M) or rebase (r) instead"],"exampleFix":"# shell fix\ngit branch --set-upstream-to=origin/$(git branch --show-current) $(git branch --show-current)\n# then 'f' works in lazygit","handlingStrategy":"validation","validationCode":"func canFastForward(b *models.Branch) error {\n    if !b.IsTrackingRemote() {\n        return errors.New(\"branch has no upstream\")\n    }\n    if !b.RemoteBranchStoredLocally() {\n        return errors.New(\"upstream ref not fetched locally; run fetch first\")\n    }\n    if b.IsAheadForPull() {\n        return errors.New(\"branch has commits to push; fast-forward not applicable\")\n    }\n    return nil\n}","typeGuard":"func isFastForwardable(b *models.Branch) bool {\n    return b.IsTrackingRemote() && b.RemoteBranchStoredLocally() && !b.IsAheadForPull()\n}","tryCatchPattern":null,"preventionTips":["Establish upstream tracking at branch creation ('git push -u')","Fetch before fast-forwarding so the local remote ref is current","Remember 'f' only moves you forward; use pull/rebase when diverged"],"tags":["git","fast-forward","upstream","branches"],"backgroundTag":null,"analyzedSha":"c477a2959b229fbf3284be0d4d2904ab61ec3c94","analyzedAt":"2026-08-15T08:34:32.451Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}