Sublime Forum

Append changes to previous commit

#1

When committing changes I would like the option to add the changes to a historic commit. Not just last commit using amend. This is for the case where a change was accidentally omitted from the correct commit and subsequent commits have been made.

The process is described here:

It is involved, but seems ripe for automation.

0 Likes

#2

I assume you’re talking about Sublime Merge.

You can easily squash any two commits in SM by selecting the two commits (with ctrl hold), opening the context menu and selecting Edit Commit → Squash Selected Commits. There are other options there, e.g. doing a fixup squash that ignores the second commit message instead of merging them.

0 Likes

#3

Thanks, that it very useful to know. The squash command had completely passed me by. I tried it with a relatively trivial case in a fresh repository. The commits in order were:

  1. Commit initial file with a single line
  2. Add two lines to the file, stage and commit only one of the lines to simulate an omission
  3. Add a fourth line commit that
  4. Commit line ‘missed’ in step 2.
  5. Attempt to squash commits in steps 2 and 4.

That resulted in a some merge errors and was alarmingly involved for resolving a file with only 4 lines in it. I am not sure if I screwed one of the merges up.

0 Likes

#4

The fewer lines you have, the more likely you are to run into conflicts with git. When the same line (or two adjacent lines) get changed in separate commits and you attempt to merge/rebase/reorder them, git isn’t able to infer your intent anymore and asks you to solve the conflict manually.

0 Likes