-
Notifications
You must be signed in to change notification settings - Fork 57
Commit Discipline
Sergej Koščejev edited this page Sep 9, 2025
·
2 revisions
When preparing a pull request for merging, squash commits to only leave meaningful commit history. In particular, remove commits like 'addressing review comments', 'force save all', 'running remigrate', etc. Ideally, each commit should contain a meaningful set of related changes to the code, changing the code from working state to another working state.
You can squash your commits into one by performing the following Git commands (or their equivalents from within an IDE):
# revert any modifications and delete untracked files in the repository to start from a clean state
git reset --hard && git clean -dfx
# get the latest state from the server
git fetch
# merge the latest state into the current branch
git merge origin/maintenance/mpsXXXX
# reset branch history to the current maintenance branch, leaving all your changes in the working directory
git reset origin/maintenance/mpsXXXX
# create a new commit with all the changes
git add -A
git commitInstead of git add -A you can stage individual changes with git add and make multiple commits.