Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### This can be done easily without `git rebase` or `git merge --squash`. In this example, let's squash the last 2 commits.
- #### If you want to squash and write a new commit message, use the command below
- `git reset --soft HEAD~2`
- ##### The `2` above points at the last 2 commit counting from the HEAD which is the top most commit in history
- ##### followed by
- `git commit`
- -----------------------------------------------------------------------------------------------------------------------------
- #### To squash and edit the combination of the existing commit messages, use the commands below
- ```
- git reset --soft HEAD~2 &&
- git commit --edit -m"$(git log --format=%B --reverse HEAD..HEAD@{1})"
- ```
- ##### The second command opens the combination of the commit messages in commits involved for editing. The last is the
- ##### commit message of the HEAD.
- Thanks
- _Copyright `@johngorithm`_
- _Software Developer @Andela_
Add Comment
Please, Sign In to add comment