git rebase -i HEAD~2
git rebase --interactive HEAD~2
- change first word of second line from "pick" to "squash"
:wq(git bash write and quit)
- 2 commit messages will show up
- usually we remove second message and leave only first message or we change first message
- push our local branch to remote with force -
git push -f
$ git rebase -i HEAD~2 pick 7357fca Commit 1 pick fc8bc9b Commit 2
Change pick to squash:
$ git rebase -i HEAD~2 pick 7357fca Commit 1 squash fc8bc9b Commit 2
Change time of last commit to current time
git commit --amend --date="now"
Git bash / vim - replace replace pick with squash
Above command will replace pick with squash from 2nd to 17th line (commit).
If we have 5 commits to squash then:
TODO: find pick only at the beginning of the line.