Command Line

Squashing is a really simple way to merge some commits.

$ git log
commit 4bd83a06ad4609eaafafc093f96849f17060593c (HEAD -> refactor/some-refactoring, origin/refactor/some-refactoring)
Author: My Name <48761+thatuser@users.noreply.github.com>
Date:   Thu Sep 26 17:25:08 2019 +0800

    Another initial commit message

commit b8d1997e4ee132075b49f958a38eeebc013d094d
Author: My Name <48761+thatuser@users.noreply.github.com>
Date:   Wed Sep 25 10:05:04 2019 +0800

    Initial commit for Terms

commit aef327c33d0521f6e1a19d3a5eca2190509f471b
Author: Kris <kris@memmee.eu>
Date:   Tue Sep 24 12:04:34 2019 +0000

    Some really important stuff

commit d6d856c32fbed3bb6bbc03f3879352e4c9629ca0
Merge: 2e6e7075 0e3a91e1
Author: My Coworker <mycoworkers@mailmail.com>
Date:   Mon Sep 23 15:48:01 2019 +0800

    Merge pull request #1002 from user/feature/refactor-some-task
    
    The really awesome commit message

The last two commits should probably merged. There won’t be two intial commits

git rebase -i HEAD~[N]

$ git rebase -i HEAD~4

This command would result in the following:

pick d94e78 Another initial commit message
pick 4e9baa Initial commit for Terms
pick afb581  Some really important stuff
pick 643d0e Merge pull request #1002 from user/feature/refactor-some-task

Change this to the following:

pick d94e78 Another initial commit message
squash 4e9baa Initial commit for Terms
pick afb581  Some really important stuff
pick 643d0e Merge pull request #1002 from user/feature/refactor-some-task

This will result in merging the last two commits:

pick d94e78 Another initial commit message
pick afb581  Some really important stuff
pick 643d0e Merge pull request #1002 from user/feature/refactor-some-task