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

Support fixup workflow #2019

Open
Mirko-von-Leipzig opened this issue Jan 22, 2024 · 8 comments
Open

Support fixup workflow #2019

Mirko-von-Leipzig opened this issue Jan 22, 2024 · 8 comments

Comments

@Mirko-von-Leipzig
Copy link

Mirko-von-Leipzig commented Jan 22, 2024

Is your feature request related to a problem? Please describe.
I'd love a shortcut for git commit --fixup <SHA> from within gitui. Here is an article describing a common use case for it, but I'll give a short summary.

What this does is create a new commit with fixup! <target <SHA> commit message>. You can then run git rebase -i --autosquash to squash the fixup commits into the target commits. This allows you to defer fixes/ammends to previous commits without messing with git history.

A nice use case is when a PR is under review. It let's you mark changes to existing commits without the reviewers losing track of what's been reviewed (as you would if you did git commit --amend or a rebase). Once the PR is approved you neaten the commit history using git rebase -i --autosquash.

Describe the solution you'd like
I'd like a new shortcut on the commit panel to trigger a git commit --fixup <SHA>. e.g. ctrl-f. This would bring up a view similar to the logs panel which would allow choosing the commit to fixup.

To be clear - this would only perform git commit --fixup <SHA> and not git rebase -i --autosquash. No rebase should be involved.

Describe alternatives you've considered
Current workflow is:

  1. Stage changes
  2. Find the commit in logs view, copy the commit hash
  3. Exit gitui
  4. Manually git commit --fixup <PASTE>
  5. Re-enter gitui, continue

Additional context
This was previously requested in #829 which was closed as completed - I think incorrectly as I commented.

I've created a new issue instead of attempting to resurrect that one.

@extrawurst
Copy link
Collaborator

@danriedl
Copy link

heck yeah, +1 for amend.

@wpcarro
Copy link

wpcarro commented Feb 3, 2024

Whatever Magit's doing in Emacs for its "instant fixup" appears to "just work" (IOW... DWIM)

btw - ty @extrawurst for making a sweet tool :)

@Chinchzilla
Copy link

+1 this is a feature I miss the most after coming from LazyGit

@Dotrar
Copy link

Dotrar commented Feb 2, 2025

Hey all, just chiming in: if some of you don't know about it, there is git-absorb which is written in rust. this does --fixup for you automatically, which is handy.

I had a quick look around, and it seems to be using git2 under the hood, so i'd say it should be possible to have in gitui as well.

The workflow I'd picture is:

  • stage some files
  • go to log (2)
  • if there's staged files, then [f] is available to just commit as a fixup. pop up the editor to add a message as well.

You can kinda already do this with what we've got:

  • stage some files
  • go to log (2)
  • [y] to copy the target commit sha, [ret] to remove popup (would love to remove this popup tbh)
  • then [1] [c] and just type "fixup! [paste][ret][ret] message".

It's trivial to implement; I'm not a rust programmer but i could give it a go..

@Dotrar Dotrar mentioned this issue Feb 3, 2025
4 tasks
@Dotrar
Copy link

Dotrar commented Feb 13, 2025

I tried adding a PR as to the above, but it got knocked back a bit.

I think we're wanting a "interactive rebase" instead. We're still not sure about the UX of this feature.

@loserMcloser
Copy link

+1 for having a fixup feature.

From the comments to #2505:

For fixups, it's best to do it the manual method of copying the sha and having a git message template

Hard disagree. Having

fixup! <long-commit-hash>

in your commit history is much less readable than having

fixup! <commit-subject-line>

which is what commit --fixup does by default on the CLI.

@Dotrar
Copy link

Dotrar commented Feb 18, 2025

I agree. That could be a small modification to my pr.

Also if you are using --autosquash then that's a non issue, imo.

I think we need to explain the UX of fixup! - it seemed like it was unintuitive to use the log to find the target commit. But I don't know where else it would come from. (Other than being blocked by the interactive rebase feature)

I didn't have much room to argue and I don't know enough rust to make it a easy-to-merge change.

(I'm now working on my own tool to do this instead (In python, which I'm a bit better at))

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

Successfully merging a pull request may close this issue.

7 participants