andromedarabbit
7/22/2015 - 1:56 AM

Squash Commits with Git

Squash Commits with Git

# ref: http://davidwalsh.name/squash-commits-git

# switch to master branch
git checkout master

# ensure our master is up to date
git pull remoteRepoName master

# use git rebase to consolidate
git rebase -i master

# Edit the summary shown to you by the rebase command, leaving the commit you want to be the main commit as "pick" and changing all subsequent "pick" commands as "squash":
#
# pick fb554f5 This is commit 1
# squash 2bd1903 This is commit 2
# squash d987ebf This is commit 3

# Force a push
git push -f