How can I squash a range of git commits together given starting and ending SHA’s

If the first SHA is HEAD you can also use this approach:

git reset --soft $OLD_SHA; git add -A; git commit --amend --no-edit

be careful, this command will change the history of the repo.

If you want to squash commits that are in the middle of your history:

|---* --- 0 --- 1 ---- 2 --- 3 --- * --- * --- * --- HEAD

like in this case the commits 1, 2 and 3

I would really recommend to use rebase -i

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)