Created
March 26, 2023 00:03
-
-
Save groovyghoul/30bf4797587b9eeecbd96306ffac2f55 to your computer and use it in GitHub Desktop.
Git: How to squash all commits, reset history on main branch ( 1 clean commit on master)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
git commit-tree HEAD^{tree} -m "new base commit message" | |
``` | |
copy the SHA | |
``` | |
git reset [SHA] | |
git push origin -f main | |
``` | |
Note: on Windows, it is easier to use CMD and change the first command to | |
``` | |
git commit-tree HEAD^^{tree} -m "new base commit message" | |
``` | |
since Windows uses ^ as an escape character |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment