0

In my commit history top commits look like so:

1ccb0058e833d9765a3a1de2816fd408dde82305 Merge branch 'master' of https://github.com/...
d462898e3a1dbd979b38bcec6d45991da0bca1e7 Add one cool feature
7e2f382e89448b7239b45f73f3b5be360435a0e6 Fix code styles
ce6b7f9ce11e06347e05aec4bfb21fea6b3b5b37 Add one cool feature

I want to combine Add one cool feature, Fix code styles and Add one cool feature into one commit and then merge back to master branch. What is the correct way to do this?

Jacobian
  • 10,122
  • 29
  • 128
  • 221

1 Answers1

1

You can use git rebase -i HEAD~4 and change pick to f (or s) on the commits you would like to squash. Then you have to force push.

Doompickaxe
  • 194
  • 1
  • 9
  • 1
    I did it with `git reset --soft HEAD~4` and pushed with `--force`. Now I see, than one extra commit was squashed. So, it seems like instead of `HEAD~4`, it should be `HEAD~3`, but how can I revert history? – Jacobian Oct 13 '19 at 17:36
  • Just with rebase again, you can use `d`(for drop) to remove that commit again – Doompickaxe Oct 13 '19 at 17:40
  • 1
    Try `git reset --hard 1ccb0058e833d9765a3a1de2816fd408dde82305 ` and see if that works (top most hash from your question) – Lasse V. Karlsen Oct 13 '19 at 17:41