Search code examples
bitbucketgit-push

git push not working on a bitbucket repository


I've just created a repository on my Bitbucket account. I have a code already written in my laptop. Here's the command I executed on my terminal:

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

I got the following error:

 ! [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.

I've tried several git pull as suggested in the message with no sucess.

Can somebody help me ?


Solution

  • It's because the remote repo and your local repo are not in sync.

    See what the error logs hints

    Do this:

    git pull origin master
    git push origin master
    

    or git push -f origin master to override remote changes.