+1

Fixup a past commit and rebase autosquash

Cyril DD 2 days ago updated by Jeff Jensen 18 hours ago 1

Ability, when committing changes, to fixup a past commit (if there are no merge conflcts for subsequent commits)

Suppose I have committed 

A > B > C 

..in that order. I realize I missed something on commit B, if I want to fix it I have to introduce a new Commit D, and make an interactive rebase to move commit D so it becomes A > B > D > C and merge commit B and D (we often refer to part of this process as a fixup)

I suggest improvements to the smartgit interface to be able to perform this automatically. Note that this procedure is now facilitated by the --fixup param when committing as explained here

Idea : in the commit window, we already have a "select" menu that can help copy previous messages. Introduce a similar "fixup" select menu, which allows selecting a commit similarly to "select", but when a previous commit is selected this way, transform the "commit" button so it becomes a "fixup" button and actually performs

git commit --fixup=[selected commit ref] # Commit indicating a fixup
git rebase -i --autosquash [selected-commit-ref]~1 # merge fixup commit into broken commit

(ans similarly for the other button "fixup and (force) push"

Image 941




References

https://stackoverflow.com/questions/3103589/how-can-i-easily-fixup-a-past-commit

Missing Git feature Commit dialog Improve Git commands Command line options
+1

SmartGit already greatly eases this process, just not using the prior commit select list.

Configure SmartGit:

  • Set SmartGit preference Low-level properties "git.rebaseInteractive.autoSquash" to "true".
  • Set SmartGit preference Low-level properties "log.useCommitMessage.prefix" to "fixup! ". note the space after !

Then can:

  1. Select the commit to fixup, press Ctrl+Shift+k (from graph or log window).
  2. See SmartGit populate the Commit view with the commit message prefixed with fixup!.
  3. Commit.
  4. Select the commit to rebase interactive from and do it.
  5. See SmartGit has autosquashed.