Last active
January 22, 2023 08:44
-
-
Save pyqlsa/b6b5da23a8197c5b139a0ff4bee2e719 to your computer and use it in GitHub Desktop.
git squash commits on main branch
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
# this should get everything down to a single commit | |
# | |
git checkout --orphan tmp-main | |
git commit -m "initial commit" | |
# move the local branch | |
git branch -f main | |
git checkout main | |
# delete the temp branch | |
git branch -d tmp-main | |
# git push --force | |
# this one leaves the initial commit in place, but squashes everything else | |
git reset --soft $(git rev-list --max-parents=0 HEAD) | |
git commit -m "initial release" | |
# git push --force |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment