mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-10-06 05:57:38 -04:00
When somebody else rebases a branch and force-pushes it, the local branch is left diverged from it, so `f` refuses to touch it. To get back in sync, the branch has to be checked out and pulled, and for a stack of branches that means doing it once per branch. Such a branch has none of its own work in it, though: the commits it is ahead by are the old versions of the ones that are now on the remote branch. So when the branch has diverged and none of the commits it is ahead by is ours, reset it to its upstream instead of refusing. This is the same state that checking the branch out and pulling it would produce, as rebase drops commits that the upstream already has. A branch that isn't checked out anywhere is reset with the same `git update-ref` that a fast-forward uses. One that is checked out somewhere is reset with `git reset --keep`, and only when that worktree has no changes to tracked files, so that the files under the user's feet change no more than they have to. `--keep` also refuses to overwrite an untracked file that the reset would bring in, which `--hard` would do silently. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>