Is there any way I can squash all the previous commit before creating a new branch. I want a clean commit page in bitbucket so that everything on the master branch before the creation of the new branch shows as only 1 commit.

I know the other options of squash while merging a branch or while pushing a branch. I found another answer in stackoverflow which tells how to squash your commit before pushing by using "git rebase -i", but I was looking for an option to squash the commits in the new branch.