Skip to content
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

Feature request: add option to fixup selected commit #96

Open
christian-steinmeyer opened this issue May 23, 2024 · 2 comments
Open

Feature request: add option to fixup selected commit #96

christian-steinmeyer opened this issue May 23, 2024 · 2 comments

Comments

@christian-steinmeyer
Copy link

I'd like to be able to right-click a commit in the graph view and be able to create a fixup commit for that commit based on the currently staged changes.

@phil294
Copy link
Owner

phil294 commented Nov 29, 2024

Hi,
why not use VSCode's "commit amend" feature? Is it because you want to modify older commits?

I'm unsure on how to do that. GitLG internally just uses shell-commands that are valid on both Windows and Unix systems. Do you have any idea what the command would look like? Sounds like history rewriting stuff. There are two similar commands in place already. This one is for editing the commit message:

git diff-index --quiet HEAD && git merge-base --is-ancestor "{COMMIT_HASH}" HEAD && git commit --allow-empty --only -m "amend! {COMMIT_HASH}\n\n{NEW_COMMIT_MESSAGE}" && git -c sequence.editor=: rebase -i --autosquash "{COMMIT_HASH}^"

But apart from that, is fixuping the staged changes into an existing commit an action common enough to warrant a place in the default commit actions (which you can augment yourself)?

Also the difference between squash and fixup in this context seems to only be regarding the commit message (??). For message editing, there's already said other command so I wouldn't worry about that, we're in rare use case territory already anyway.

So yeah I guess we can do this but I definitely need some sample commands and guidance here.

@christian-steinmeyer
Copy link
Author

Thanks for the response!
Exactly, it is meant to "amend" an older commit while maintaining the original commit message (meant for e.g. typos, small mistakes etc.). It would be autosquash-able for easy rebasing, but in my case, I use it for the following workflow: I work on my own on a feature branch and create a merge request. Then someone reviews the MR. I address the requested changes either in new commits (if I add something new) or in fixup commits (if I made mistakes). I have It re-reviewed with nice UX for the reviewer and once everyone is happy, I simply rebase with autosquash enabled and voila, I have a nice branch that can be merged.

A command might look like git commit --fixup [SOME_COMMIT_SHA].

Admittedly, I'm afraid that fixup commits for many are an advanced topic (but in my personal opinion, they shouldn't! and having nice integration tools like this might help in that regard). I know that I would use it for sure! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants