Skip to content

Force Git Squash and Git Rebase before every PR being merged #6802

Open
@Ayush23Dash

Description

@Ayush23Dash

Improve Git commit History

Issue

As of now, the entire p5.js repository does not follow squashing down all of the commits of a PR to one commit and then rebasing the branch with main branch before merging a PR.

This creates a messed up commit history. Squashing down commits improves readability throughout the git log.

Steps to squash Down Commits to one commit

  • To squash down 'n' number of commits:

    git rebase -i HEAD~n

  • This will open up your editor of choice for Git. The default is Vim.

  • Now, you need to replace all those pick with squash (or simply s) apart from the first one.

Note - pick or p will only use those commits, but squash or s will use them and combine them all together.

  • The first commit is the one you will combine them into without losing your changes.
  • After doing that, save the file and close it. Git will open up another editor where you can see the new commit message it generates for you.
  • You can get rid of all of them and add your custom message.
  • After doing that, you should see a success message in the terminal.

Steps to rebase the PR branch with main branch

  • Checkout to main and git pull upstream main
  • Checkout to PR branch and git rebase upstream/main
  • There are chances git conflicts will come in your changed files, remove them manually and carefully.
  • Add the unstaged changes to git staging area : git add .
  • git commit -m “Original commit message that you used earlier”
  • git rebase --continue
  • To push the changes to the online PR : git push -f origin [branch name]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions