My topic branch is about 20 commits ahead of where I branched from.
I would like to automatically squash all these commits into the first commit after the branch.
I know I can do this interactively with rebase, but I don't want to interact, just fire off the command.
You could do it this way:
git reset --soft HEAD~20
git commit -m "massive commit"
A quick way to find the exact commit you want to reset to is to do
git merge-base <topicbranch> <otherbranch>
If the output of that is <commit-ish>
, you can then do
git reset --soft <commit-ish>