Usually happens when just create new repo in Bitbucket and auto create .gitignore. It will conflict with our local repo which hasn't been registered in any external repo.
The error is resolved by toggling the allow-unrelated-histories switch. After a git pull or git merge command, run the following command:
git pull http://bitbucket.org/etcetc master --allow-unrelated-histories
Provided that you already setup the merge tool to your favorite software (Kdiff3 or others) :
git mergetool
Compare to HTTPS, using SSH is more secure. You never send your username and password accros the network. For a private repository, SSH is much preferred.
1. Create key pair for your account. Put your email as Comment (CLI option -C) on this key. If you use the same email for Bitbucket, Github, and Gitlab, you can use the same key for all of them. Using different key is more secure. If one key compromised, the other key is still secure. For refreshment about SSH, see OpenSSH
ssh-keygen -t ed25519 -C "jim.merari@gmail.com"
2. Go to your account setting menu in bitbucket.org/github.com/gitlab.com. Find the page related to SSH/GPG. The page will list all the keys that have been associated with your account. Copy the content of your newly generated public key to the corresponding setting form. See more detail on each respective website (Bitbucket, Gitbub).
After the new key listed, then you can push/fetch with the command :
git push ssh://git@github.com:jmerari/some-repo.git git push ssh://git@bitbucket.org:jmerari/some-repo.git
https://blog.developer.atlassian.com/different-ssh-keys-multiple-bitbucket-accounts/