Skip to content

Instantly share code, notes, and snippets.

@luiarthur
Last active June 5, 2020 17:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luiarthur/9586618edec5b6289cdb13256a7c3a6e to your computer and use it in GitHub Desktop.
Save luiarthur/9586618edec5b6289cdb13256a7c3a6e to your computer and use it in GitHub Desktop.
Merge and squash a git branch
# Say you are working on a branch called `my-branch`
# and you wish to now merge it into `master`, and
# squash all commits from `my-branch` into one commit.
# You can do the following:
git checkout master
git merge --squash my-branch
git commit
# You will then be placed in an editor with all your previous
# commits. First, add a one-liner at the top. Then, feel free
# to rewrite or remove the previous commit logs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment