I have a bunch of commits on my local repository which are thematically similar. I'd like to combine them into a single commit before pushing up to a remote. How do I do it? I think rebase does this, but I can't make sense of the docs.
I have a bunch of commits on my local repository which are thematically similar. I'd like to combine them into a single commit before pushing up to a remote. How do I do it? I think rebase does this, but I can't make sense of the docs.
There are quite a few working answers here, but I found this the easiest. This command will open up an editor, where you can just replace pick with squash in order to remove/merge them into one
git rebase -i HEAD~4
where, 4 is the number of commits you want to squash into one. This is explained here as well.
If you are looking to squash the commits which also includes the very first commit, then use this command
git rebase -i --root