Ever had to change something about all the commits in a git repo before pushing it to a remote? As in from the very first commit in a repo? Maybe you’ve started a repo locally and when you’re ready to push it, you realize that you’ve used the wrong author or messed up the format of the commit messages; or maybe you just want to squash those first few commits into a single concise package.
In these situations, my first response is to do to an interactive rebase (git rebase -i
). Usually when I’m rebasing, though, I’m in a project that has an upstream and where I’m rebasing off a specific commit or branch. For situations where you don’t have a commit to rebase off, but you want to rebase the entire history or at least the very first commit: What do you do?
The answer, my friend, is that you pass the --root
option:
git rebase -i --root
That’ll let you pick, reword, edit, squash, fixup, exec, drop, label, reset, or merge all of your commits from the ‘dawn of time.’
Have fun!
Top comments (0)