Skip to content

Instantly share code, notes, and snippets.

@AsadDevAI
Created November 29, 2019 10:15
Show Gist options
  • Save AsadDevAI/40ad1edf781a8479f40099e781ea9d84 to your computer and use it in GitHub Desktop.
Save AsadDevAI/40ad1edf781a8479f40099e781ea9d84 to your computer and use it in GitHub Desktop.
How to squash commits
When submitting a pull request to Project, we ask that you squash your commits before we merge.
Some applications that interact with git repos will provide a user interface for squashing. Refer to your application's document for more information.
If you're familiar with Terminal, you can do the following:
* Make sure your branch is up to date with the master branch.
* Run `git rebase -i master`.
* You should see a list of commits, each commit starting with the word "pick".
* Make sure the first commit says "pick" and change the rest from "pick" to "squash".
-- This will squash each commit into the previous commit, which will continue until every commit is squashed into the first commit.
* Save and close the editor.
* It will give you the opportunity to change the commit message.
* Save and close the editor again.
* Then you have to force push the final, squashed commit: `git push --f origin <branch name>`.
Squashing commits can be a tricky process but once you figure it out, it's really helpful and keeps our repo concise and clean.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment