Guest User

Untitled

a guest
Jan 23rd, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. ### This can be done easily without `git rebase` or `git merge --squash`. In this example, let's squash the last 2 commits.
  2.  
  3. #### If you want to squash and write a new commit message, use the command below
  4. `git reset --soft HEAD~2`
  5. ##### The `2` above points at the last 2 commit counting from the HEAD which is the top most commit in history
  6. ##### followed by
  7. `git commit`
  8.  
  9. -----------------------------------------------------------------------------------------------------------------------------
  10. #### To squash and edit the combination of the existing commit messages, use the commands below
  11. ```
  12. git reset --soft HEAD~2 &&
  13. git commit --edit -m"$(git log --format=%B --reverse HEAD..HEAD@{1})"
  14. ```
  15. ##### The second command opens the combination of the commit messages in commits involved for editing. The last is the
  16. ##### commit message of the HEAD.
  17. Thanks
  18.  
  19. _Copyright `@johngorithm`_
  20. _Software Developer @Andela_
Add Comment
Please, Sign In to add comment