Skip to content

Use "git cherry-pick" instead of interactive rebase to implement cherry-picking #3317

@stefanhaller

Description

@stefanhaller

We are currently using an interactive rebase to implement cherry-picking. The main reason for doing this is that when you cherry-pick multiple commits, and one of them conflicts, then you get lazygit's nice visualization of the rebase todo list to show you where in the sequence you are, what the conflicting commit is, how many are left etc. Another advantage is that this makes it easy to support cherry-picking in the middle of an interactive rebase, by just inserting the pasted commits as "pick" entries into git-rebase-todo at that point.

The downside is that cherry-picking merge commits is not supported this way, since the "pick" command doesn't work with merges (see this mailing list thread). Cherry-picking merge commits is a useful and requested feature though, see #1374.

If we add a way to visualize the .git/sequencer/todo file (which is used by git during cherry-picking) in a similar way to how we do for .git/rebase-merge/git-rebase-todo (just read-only), including the logic to show the fake "conflict" entry, then we could use git cherry-pick -m1 for implementing copy/paste, which would then work for merge commits.

The downside is that it's much more complex to do; especially for the case that the cherry-pick happened in the middle of an interactive rebase, and conflicted. Our todo section would then have to show a merged view of both .git/sequencer/todo and git-rebase-todo.

All of this is very similar to what we would have to do to support #2442.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions