Skip to content

Instantly share code, notes, and snippets.

@groovyghoul
Created March 26, 2023 00:03
Show Gist options
  • Save groovyghoul/30bf4797587b9eeecbd96306ffac2f55 to your computer and use it in GitHub Desktop.
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)
```
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