This note explains how to squash commits in Git. If you find any incorrect information, kindly correct it. Additionally, please feel free to ask any questions or leave comments if you encounter any issues.
When trying to resolve project issues, sometimes you need to commit multiple versions to record the work log. After sending the PR, the changes may not comply with the contribution rules, and you have to fix them. As a result, you end up with numerous commits that don't pertain to this particular PR, but only reflect your work log.
The project owner likely wants to concentrate on the final changes you made, rather than your work log. To address this, we need to squash the commits.
Given the git log shown below, I want to squash the commits after upstream/master
into one commit.
origin/master
to upstream/master
The new logs show below
We have the option to modify actions for individual commits:
The new logs show below
The new logs show below
Feel free to send your pull request to contribute to the project!