Skip to content

Instantly share code, notes, and snippets.

@devdrops
Created September 15, 2016 17:54
Show Gist options
  • Select an option

  • Save devdrops/0dd11a24d05314fcc8a113590a709b9f to your computer and use it in GitHub Desktop.

Select an option

Save devdrops/0dd11a24d05314fcc8a113590a709b9f to your computer and use it in GitHub Desktop.
Squash several commits into one

Squash several commits into one

From https://makandracards.com/makandra/527-squash-several-git-commits-into-a-single-commit (with few changes on the end by me 😉)

# Switch to the master branch and make sure you are up to date.
git checkout master
git fetch # this may be necessary (depending on your git config) to receive updates on origin/master
git pull

# Merge the feature branch into the master branch.
git merge feature_branch

# Reset the master branch to origin's state.
git reset origin/master

git branch -D feature_branch && git checkout -b feature_branch

git add .
git commit -m 'yada yada'

git push origin feature_branch -f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment