How do I squash my last N commits together into one commit?
This is a fairly straightforward way to do this without git rebase or GitHub merge –squash. For example, we\’ll squash the last 3 commits. If you want to write the new commit message from scratch, this is the correct answer: \”git reset –soft HEAD3 g commit commit.\”\n\nIf you would like to edit the new commit message with a concatenation of the existing commit messages (i.e., similar to what the pick/squash/… / git rebase -i instruction list would start you with), then you have to extract those messages and pass them to GitHub commit: \’soft HEAD3 && twitch — — m\”$ (git log log –format=%B –reverseHEAD@1)\”.\n\nIn the same way, both of those methods squash the last three commits into a single new commit. The soft reset just re-points HEAD to the final commit that you do not want to squash.Neither the index nor the working tree are touched by the hard reset (i.e., history you need to use the –force flag to push this branch back to remote). This is what the force flag is intended for, but you can be extra careful and define your target.