I have a brand new git repo. It has three commits.
I'd like to squash them together so my project history looks clean, and others don't see my hacky commits.
Obviously nobody else has seen the repo, as it's brand new, so changing history is not a problem. I am the only user.
However git rebase -i
wants me to track an upstream branch. I don't want to publish anything until I've tidied up the git log.
How can I do a interactive rebase, or squash commits in general, without tracking an upstream?
You can skip tracking a remote branch by specifying the last
n
commits you want to squash.For eg. if you have 4 commits in your branch and you want to squash the last 3 commits effectively making a single commit, you can do
git rebase -i HEAD~4
. You can then either fixup or squash the commits as you wish.