1

I have several "save point" commits and would like to squash them to have a more readable timeline. Here is my situation:

> git log

29a94be3d2d4f Added some feature
9bf0f2730234e savepoint          << Pushed here 
240e1ce8893e9 Add ignore rule
01462e889d416 savepoint
6238e3b775027 Fixed Something    << Pushed here
0d485486a42a9 Update Version
......
06ad9e4fc5f64 savepoint
1462e57657434 Initial Commit

And I would like to have

29a94be3d2d4f Added some feature
240e1ce8893e9 Add ignore rule
6238e3b775027 Fixed Something
0d485486a42a9 Update Version
1462e57657434 Initial Commit

Is there a way to script this, so I can say:

git squash -commits-with-log="savepoint" ~FROM_INITIAL_COMMIT

gevik
  • 3,177
  • 4
  • 25
  • 28
  • 2
    What does your `<< Pushed here` notation indicate? If you have pushed these to some remote server, or otherwise made them published, any changes you make at or before those points will require that anyone else who is *using* these published commits, *also* take action. If that's OK, you can rebase-to-squash; if not, you can't. – torek Jun 11 '16 at 08:51
  • That reminds me of http://stackoverflow.com/a/2302947/6309, but it doesn't exactly apply in your case. – VonC Jun 11 '16 at 10:19

1 Answers1

0

Update: It seems that the trick is in GIT_SEQUENCE_EDITOR variable

gevik
  • 3,177
  • 4
  • 25
  • 28
  • To expand on that, [here](https://stackoverflow.com/a/46403701/5037965) is a long-ish answer that uses `GIT_SEQUENCE_EDITOR` to automate using `git rebase -i` for squashing similar commits. – John Vandenberg Sep 25 '17 at 11:38