p5.js
p5.js copied to clipboard
Force Git Squash and Git Rebase before every PR being merged
trafficstars
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]