-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stacked PRs in lazygit #2527
Comments
I haven't worked with tools like Before thinking about adding features to manage stacked branches to lazygit, we first need to fix a few basic things that are broken right now:
I'm working on fixing both of these right now (2nd first). After that, the next thing I'm missing is to somehow visualize the individual branch heads of the stack in the local commits panel. They are visible when you expand the panel using Once all these are done, I'd be happy and wouldn't need any more support for working with stacked branches. But that's only my personal opinion, others might disagree. |
The two issues mentioned above are fixed in the 0.38 release, so support for stacked branches is a lot better now. Visualization of branch heads in the local commits view is not great yet. You have to opt in to it by turning on the There are a few remaining issues for me:
If you have other issues with support for stacked branches besides there, I'd be interested to hear about them. |
I love that lazygit is working toward support for these types of workflows!
I think it would be nice if the local branches visualization showed a tree view that reflected the stack of branches. For example, graphite's
Another thing I'd love to have from a stacked branch feature set is integration with worktrees. e.g., instead of operating on the branches in the stack only in the current worktree, move to the existing worktree location for each branch during the operation. |
I came here to ask for this feature so I'm happy I found it. My use case is that I normally do a first PR of typically "cleanup and upgrades" followed by "implement feature A" followed perhaps by "implement feature B". Normally I get all of those done before the first one gets reviewed. Then, after amending the first PR after review comments, I rebase the other two in order. I have to remember the order (so I try to name them cleverly). I also normally do this rebase interactively and drop commits that originally came from the first (or second) branch to just apply the diff added by this branch/PR. So, I (thumbup) and (vote) for this one and I'm happy to test it out on a beta. |
@wederbrand What you describe is a workflow I use very frequently. I often stack two, three, or sometimes four branches onto each other, and work with them using lazygit. I find that lazygit does a decent job of supporting this workflow, if you pay attention to a few basic rules. I only had a brief look at git-town's stacked branches documentation that you linked to above, and it doesn't strike me as superior; it seems that you have to do a bit of manual maintenance (e.g. call With lazygit (or stock cli git for that matter), what you have to keep in mind is to always work on the topmost branch of the stack. Keep that branch checked out at all times, even when working on the lower branches. This way, whenever you do any kind of history rewriting (amending commits, moving commits up/down, etc), you stack stays intact. The only time you have to manually fix your stack is when a coworker "helpfully" pushes a fixup commit to one of the lower branches. This workflow has a few consequences:
Let me know if anything is unclear, or if you are missing other functionality (besides the ones that were already mentioned above). |
I'm sure I follow, or I do it wrong. If have stacked branches A (bottom of stack), B and C (top of stack) and I'm working on C but the change I'm doing is for one of the commits in A. I would do the change, stage it and then select a commit from A and do shift+A to amend it to that one. What git-town does (and I'm not saying it does it well) is to allow me to switch to A, do the amend, and then switch back to C and sync it. All of A, B and C are now correctly pointing to each other and the remots have been updated. |
Sounds like you don't have the
That's the thing, I don't want to have to switch to A and back to C, or do some manual syncing. |
Excellent! My work flow predates 2.38 and apparently I haven't been paying attention ;) |
When using stacked commits after moving a commit across branch boundaries with |
I find lazygit's support for stacked branches already quite good (in 2025), even if some QoL things could be added. What really I would love seeing (not a Go dev unfortunately...) is the option to also push all branches in the stack. I already can see them since I get the little "branch icon" when I'm at the top of the stack, and lazygit correctly implements Lazygit has all the information it needs already to do this automatically, right? Since it's able to place the branch icons in the commit list, it should also be able to get the same branches and push them one by one. Is this feature already there, and I'm just not aware of it? |
Have a couple of suggestions that I believe aren't covered in this thread:
|
@PeterCardenas I'm confused; I do both of these things all the time, and they work great with stacked branches. I can think of no reason why they don't work for you, but squashing fixups does. And I don't even know what clarifying questions I can ask to get to the bottom of this. Still, can you describe a specific scenario in more detail? |
Is your feature request related to a problem? Please describe.
I'm interested in incorporating stacked PRs into a lazygit workflow:
https://benjamincongdon.me/blog/2022/07/17/In-Praise-of-Stacked-PRs/
https://timothya.com/blog/git-stack/
I don't yet have a clear vision of how this would work in lazygit, but the overarching goal is to be able to make several related, simultaneous pull requests (each with 1 or more commits) in Github (or similar). Given feedback from the PRs, I'd like a way to edit the commits within PRs, or re-sequence the PRs in lazygit, or omit / introduce new PRs in between existing PRs.
Describe the solution you'd like
This is more of a "call for ideas" than a concrete solution. Has the concept of stacked PRs been discussed? Are there existing solutions that work well with lazygit? Would it make sense to use a command like
git-stack
, or would a custom implementation specific to lazygit make more sense?Additional context
I'm exploring command-line tools like
gh-stack
,git-stack
, andgit-branchless
. There are also possibly-commercial options out there such as graphite (gt
).The text was updated successfully, but these errors were encountered: