The problem was bitbucket was creating a .gitignore which is created by the template when creating the local repository. So I configured the bitbucket repository to not create this file. Then I used
git remote set-url origin <bitbucket_URL>
to set the correct repository url. Then
git push -u origin --all
This worked.