Skip to content

Instantly share code, notes, and snippets.

@ariesshrimp
Last active July 24, 2017 22:10
Show Gist options
  • Save ariesshrimp/f4044cbef99ffef6fb41edd62c363d9a to your computer and use it in GitHub Desktop.
Save ariesshrimp/f4044cbef99ffef6fb41edd62c363d9a to your computer and use it in GitHub Desktop.
Squash several Git commits into a single commit
# https://makandracards.com/makandra/527-squash-several-git-commits-into-a-single-commit
# 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 now considers all changes as unstaged changes.
# We can add these changes as one commit.
# Adding . will also add untracked files.
git add --all
git commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment