You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As you know, when committing a fix for the latest commit, you can run git commit --amend to directly modify that commit
Committing a fix for an older commit can also be done, but in two steps
Passing --fixup XXX to the git commit command (where XXX is the commit's hash) creates the commit, gives it a fixup name, and marks it as a fixup commit for XXX
Passing --autosquash to git rebase -i automatically moves fixup commits after the relevant commits (if they're listed), an puts the "fixup" keyword in front of them instead of the default "pick"
The issue:
sourcegit does not support those options
More generally, it does not try to make it easy for the user to handle fixup commits (beyond the existence of an interactive-rebase window)
Possible solutions:
The most direct approach would be to separately implement both options:
When right-clicking on a commit, add an option Commit staged changes as a fixup to here
In the interactive-rebase window, add at the top a button Toggle autosquash (maybe with a warning that it cancels and replaces the current interactive rebase if someone had started to edit it)
A more integrated approach would be to allow the user to get the same result without exposing the underlying git commands
When right-clicking on a commit, add an option Try to integrate the staged changes as a fixup to here (using rebase)
Which runs git commit --fixup XXX (because it creates a commit with a proper name)
Then runs git rebase -i on the commit's parent (without autosquash to avoid side-effect)
Then sets the fixup commit after XXX with the "fixup" keyword in front of it
Then triggers the rebase as if the user has done all that manually (i.e. let them handle conflicts as usual)
If you choose that solution, you can reuse the logic to implement an additional feature : when right-clicking on a commit with other commits selected , add an option Try to squash the selected commits to here (using rebase)
Which runs git rebase -i on the commit's parent
Then sets the selected commits after it with the "squash" keyword in front of them
Then triggers the rebase as if the user has done all that manually (i.e. let them handle conflicts as usual)
The context:
git commit --amendto directly modify that commit--fixup XXXto thegit commitcommand (where XXX is the commit's hash) creates the commit, gives it a fixup name, and marks it as a fixup commit for XXX--autosquashtogit rebase -iautomatically moves fixup commits after the relevant commits (if they're listed), an puts the "fixup" keyword in front of them instead of the default "pick"The issue:
sourcegitdoes not support those optionsPossible solutions:
Commit staged changes as a fixup to hereToggle autosquash(maybe with a warning that it cancels and replaces the current interactive rebase if someone had started to edit it)Try to integrate the staged changes as a fixup to here (using rebase)git commit --fixup XXX(because it creates a commit with a proper name)git rebase -ion the commit's parent (without autosquash to avoid side-effect)Try to squash the selected commits to here (using rebase)git rebase -ion the commit's parent