git push在Bitbucket存储库上不起作用

问题描述

我刚刚在我的Bitbucket帐户上创建了一个存储库。我的笔记本电脑中已经编写了代码。 这是我在终端上执行的命令:

git init
git add --all
git commit -m 'Initial commit'
git remote add origin https://<repo_owner_name>@bitbucket.org/<teamname>/<reponame>.git
git push origin master

我遇到以下错误

 ! [rejected]        master -> master (non-fast-forward)
error: Failed to push some refs to 'https://bitbucket.org/EtienneVergne/disney-app-proposal.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.

我已经尝试按照消息中的建议进行了几次git pull操作,但没有成功。

有人可以帮助我吗?

解决方法

这是因为远程存储库和本地存储库不同步。

查看错误日志提示

执行此操作:

git pull origin master
git push origin master

git push -f origin master覆盖远程更改。