lazygit
lazygit copied to clipboard
Does deleting the newest commit in lazygit is the same as git reset --hard HEAD~1?
Topic
the version is 0.37
i have a git repo commit log like this, it's a tig show in nigthtly branch. I use tig snapshot because its log graph is clear.
there is a master branch , i checkout nightly and feature1 branch from it. Then make a commit on nightly, make two commits on feature1, at last merge feature1 to nightly, no conflicts.
All the operations below is happened in nightly branch.
Then i just need to delete the top merge commit. so I delete it in lazygit by press d in commits pane. but the result is so confused.
It deletes the merge commit and also the commit I did in nightly branch and cherry-pick 2 commits of feature1 to nightly. But I think it should only delete the merge commit as git reset --hard HEAD~1 does.
Your thoughts If it's not a bug , what the exactly delete commit means in lazygit?
Checking the log shows the following happens when deleting a commit:
git rebase --interactive --autostash --keep-empty <ref-before-the-commit-for-deletion>
And then the commit is marked as drop and the rebase continues.
I'm guessing the issue here is that rebasing over merge commits is wonky, so I'm not really sure what git does in such situations.
You could use g in the commits panel which lets you pick a type of reset you want to execute.
Sorta unrelated - why do you merge and then delete the merge commit, isn't that the same as rebasing?
thank you, i noticed the command outputed in "Command Log" pane. the g command is really what i need. But all of these is counter-intuitive.

Well, d should stand for drop actually, yeah.
More, I execute the command in command log output manually, it will rebase interactively, means i can decide to drop or pick the previous commits in nightly, but lazygit drop them directly. Anyway it's a weird and dangerous operation in merge commits.
Well, rebasing over merge commits is somewhat unintuitive in general, so I do get the confusion :)
Also, why do you merge and then delete the merge commit, are you sure you're not looking for a rebase?
not rebase for sure. I just test the merge request function in gitlab, wishing to get merge commit info through gitlab graphql api but after many times merge and delete merge and merge again , I think gitlab api has a bug of unable to give merge commit info .