Skip to content

Squashing

Sabira edited this page Oct 26, 2018 · 2 revisions

Squashing is the processing of combining several commits into a single resultant commit. This is done to keep the commit history clean. I'll only explain how to do this via the command line since it's just punching in commands. You'll need a command line open pointed at your repository (use the cd command in Windows to move through directories, or open it via the File menu)

There are several ways to squash, so a few different methods will be covered.

Rebase

  1. First, you need to know how many commits you want to squash. Usually, you'll be able to look at the open pull request and it will tell you know many commits you have.
  2. After you know how many commits you want to squash, enter the command git rebase -i HEAD~# where # is the number of commits you want to squash. You'll then get something that looks like this in your text editor:
  3. The commands tell you what you can do. For our purposes, we want to set 222222, 3333333 and 444444 to squash, and 1111111 to pick. After you've done that, save and close the editor.
  4. After that, you'll get another text editor to allow you to modify the newly squashed commit message. Save and close the editor once you're finished.
  5. After you've squashed, you'll need to force push the changes up to your repo. Keep in mind that force push will overwrite all commits on this branch, which is what we need it to do in this case. In your command line, enter git push FORK BRANCH --force where FORK is the name of your personal repository (it will be 'fork', if you set up git according to the guides contained here) and BRANCH is the name of the branch.

Reset

  1. Open your command line pointed at your repository, and switch to the dev branch and ensure it's up to date: git checkout dev then git pull
  2. Now enter git merge BRANCH where BRANCH is the name of the branch you want to squash
  3. Enter git reset origin/dev, which will reset your dev branch to the main repository's version.
  4. You can now add your files to commit using either the command line (git commit -a) or your client of choice.
  5. You'll need to force push; refer to the final point in the guide above.

Documentation regarding setting up and using Git.

Making heads or tails of specific GitHub pages, for the uninitiated.

Tools

Documentation regarding tools external to DM and Git.

Documentation

Content creation guides

Standards

Standards and guidelines regarding commenting, contributor conduct and coding standards.

Clone this wiki locally