jesseduffield / jesseduffield/lazygit

lazygit Rebase/Fixup/Reword/Squash onto wrong commit (sibling branch) when git.log.showWholeGraph=true

Open
#4,997 3 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Go
Stars
82.4k
Forks
3k
Avg merge
2d 18h
Merged PRs (30d)
19

Description

### Describe the bug
When git.log.showWholeGraph is enabled or toggled using "Ctrl+L" in lazygit, rebasing or fixup/squashing/reword commits on a feature branch, a **wrong rebase base is chosen** that caused it to pulls in commits from sibling branches that share the same base (e.g., main or develop), even if those commits are unrelated to the current branch.

### To Reproduce
Steps to reproduce the behavior:

1. Create two feature branches from main
2. Open lazygit with git.log.showWholeGraph : true (edit in config.yml or toggle using "Ctrl+L")
3. Checkout feature/B.
4. Perform a rebase or fixup on B1 (e.g., squash into previous or rebase onto main).
5. Observe: Commit A1 from feature/A now appears in the commit history/log of feature/B.

### Expected behavior

1. Rebase/fixup on feature/B should only affect commits on feature/B.
2. Commits from feature/A should not be included ("pollution").
3. A rebase base should be chosen correctly.
4. This matches behavior when using git rebase directly in the CLI.

### Screenshots
If applicable, add screenshots to help explain your problem.

1. Create two feature branches, here I call it "dev-a" and "dev-b", each has two commits branching off the main branch.
Image

2. Now, I will checkout dev-b and perform "squash" by pressing "s". Observe that the "pollution" happened here, as the git graph now shows that commits in "dev-a" is being merged into the commit history of "dev-b"
Image

3. Now I revert it, still checked out to "dev-b" branch and by using git CLI to perform squash the
__DESIRED OUTCOME__ is as shown.
```sh
git rebase -i HEAD~2
```
Image
Image

4. Another example, using lazygit rebase feature by pressing "i"
Image

5. Same "pollution" happened here as well, this behavior has been replicable in fixup, reword as well, as long as the git log --all
Image

#### Here onwards showcases some of my debugging efforts
1. Using lazygit --debug and lazygit --logs, when I perform rebase using lazygit by pressing "i".
Here the base commit chosen is 333e0175a, this commit points to "dev-a" instead of "main" branch.
Image
Image

2. The function responsible for obtaining the base commits used in the interactive rebase, called by "quickStartInteractiveRebase"
Image

### Version info:

* _Run `lazygit --version` and paste the result here_
commit=3de12b7fde56cec5d0fc27b1986180c27e50d971, build date=2025-09-17T18:42:05Z, build source=binaryRelease, version=0.55.1, os=linux, arch=amd64, git version=2.43.0

* _Run `git --version` and paste the result here_
git version 2.43.0

### Additional context
Add any other context about the problem here.

> [!NOTE]
> Please try updating to the latest version or [manually building](https://github.com/jesseduffield/lazygit/#manual) the latest `master` to see if the issue still occurs.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.