lazygit
lazygit copied to clipboard
fatal: it seems that there is already a rebase-merge directory
Describe the bug I'd like to edit an old commit, but get the error message mentioned in the title.
To Reproduce Steps to reproduce the behavior:
- GIVEN a commit I'd like to edit,
- WHEN pressing "e" to edit commit
- and changing a file
- and staging that file in lazygit
- and pressing "A" to amend the commit which I originally selected with "e" (the
<-- you are herecommit) - and confirming that I want to amend the commit with staged files
- THEN I get the error message: "fatal: it seems that there is already a rebase-merge directory"
Expected behavior I assumed that the commit would be amended.
Version info:
Run lazygit --version and paste the result here
commit=367b0d331836c90c015bf0c45f88612f3d94d08a, build date=2022-07-20T09:27:56Z, build source=binaryRelease, version=0.35, os=linux, arch=amd64
Run git --version and paste the result here
git version 2.25.1
Additional context I'm running lazygit in a vscode console. Is it possible that vscode creates some files which lazygit does not expect?
I'm running lazygit in a vscode console. Is it possible that vscode creates some files which lazygit does not expect?
Try running it outside of vscode to see if it changes.
That error is appearing because in order to amend a commit other than the HEAD commit, we need to rebase. But we're already in rebase mode due to pressing 'e' on a commit.
If you're trying to amend the HEAD commit, we should be able to do that with a git commit --amend --no-edit --allow-empty. I think we were doing that previously but removed that functionality for the sake of consistency (i.e. we wanted to be running the same command regardless of whether you were acting on the HEAD commit or some other commit).
If you're trying to amend a commit other than HEAD, we should return a better error explaining that you're already in a rebase and amending an old commit requires a new rebase.
AmendHeadCmdObj (pkg/commands/git_commands/commit.go) has the code for amending the most recent commit, and amendTo (pkg/gui/controllers/local_commits_controller.go) is where we'd need to add logic to use AmendHeadCmdObj if we're dealing with the most recent commit.
To Reproduce Steps to reproduce the behavior:
* GIVEN a commit I'd like to edit, * WHEN pressing "e" to edit commit * and changing a file * and staging that file in lazygit * and pressing "A" to amend the commit which I originally selected with "e" (the `<-- you are here` commit) * and confirming that I want to amend the commit with staged files * THEN I get the error message: "fatal: it seems that there is already a rebase-merge directory"Expected behavior I assumed that the commit would be amended.
Actually you can do that in less steps, without errors:
- change file
- stage it
- go to the
Commitspanel (4) - find the commit you want to amend
- press
A
There's no need to edit the commit first.
@mark2185 although that's true, given that lazygit does allow you to take the more long-winded approach, we ought to ensure it's a good UX experience either way
Of course, I just don't want @cgebbe to be stuck until this is fixed, since there is a way to do what they want :sweat_smile:
Yep as soon as I commented I saw your PR go up haha
Doesn't the "long-winded" approach have the benefit of checking out the to-be-edited commit? That can be necessary if later commits change similar lines.
I'm not sure what you're asking, but if you just amend to a commit that's 5 commits in the past, it'll run a rebase from that point, and stop if there are conflicts.
EDIT: I re-read it, and I guess it does help with that, yeah.