Skip to content

Custom command with subcommit sha not working #5113

@lobneroO

Description

@lobneroO

Describe the bug

I'm trying to add a custom command that cherry-picks a commit without actually adding the commit (i.e. git cherry-pick -n) and then also reset such that the changes are not even staged (see also https://stackoverflow.com/a/32333564/6584985 )
Depending on how I add the command it either does not use the commit's sha and thus fails, or it does not actually do the git reset, even though the command is displayed in the lower right corner of lazygit.

To Reproduce

Version 1:

In your lazygit config add:

  - key: 'X'
    description: "Cherry-Pick but do not apply commit. Reset afterwards to unsage cherry-picked commit."
    command: git cherry-pick -n {{.SelectedSubCommit.Sha}} && git reset
    context: 'subCommits'
    output: log

Using this, the commit sha is empty and thus the entire thing fails.

Image

Version 2:

  - key: 'X'
    description: "Cherry-Pick but do not apply commit. Reset afterwards to unsage cherry-picked commit."
    command: |
      git cherry-pick -n {{ .SelectedSubCommit.Sha }}
      git reset
    context: 'subCommits'
    output: log

This does the cherry pick correctly, but as mentioned above, the git reset is not (or maybe too early?) executed.

Image Image (I tried with and without HEAD, which is why it is displayed in the screenshot. Both versions do the same thing)

Expected behavior

Either version should correctly do the cherry pick without adding the commit, the reset such that files are unstaged.
Most of all, it should be consistently work with the commit SHA (or not work in both versions)

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=windows, arch=amd64, git version=2.51.1.windows.1

  • Run git --version and paste the result here
    git version 2.51.1.windows.1

Additional context

It'd be even better to unstage only the cherry-picked changes, but I'm not sure that's possible with git...

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions