0

I'm trying to move a local repository to bitbucket, I'm following this tutorial but when I do

git push --all bitbucket 

I got the following meessage error:

To https://bitbucket.org/growtec/offshore.git
 ! [rejected]        Leonardo -> Leonardo (fetch first)
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://lrslima@bitbucket.org/growtec/offshore.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

I'm on master branch and I already did a git pull but the output was the Everything up-to-date.

I saw this question but it didn't work for me

Leonardo Lima
  • 586
  • 1
  • 6
  • 20
  • 1
    I recommend *avoiding* `git pull` entirely, but since you are using it: (1) what remotes do you have (`git remote` will list them)? (2) what is the `upstream` setting of your `master` branch name? (`git rev-parse --symbolic-full-name master@{upstream}` will show it.) (3) what is the `upstream` setting of your `Leonardo` branch name? – torek Oct 17 '17 at 17:17

6 Answers6

3

You did a git pull on the master branch, but if you look closely at what your git push --all bitbucket command is doing, it's also trying to push the Leonardo branch, which you never pulled. You can try pulling this branch as well, and then push all again:

git checkout Leonardo
git pull origin Leonardo
git push --all bitbucket
Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
3

If everything is already up to date. Try git push -f origin master. -f stands for force commit. Hope this helps.

rased
  • 136
  • 2
  • 6
2

You need to pull (or fetch and merge) the 2 branches master and Leonardo solve all the conflicts commit then push again

Pascal Fares
  • 21,959
  • 2
  • 14
  • 12
1

just this code using terminal :

git push -f origin master

Seda T.
  • 161
  • 1
  • 4
0
git pull origin master
git fetch origin Leonardo:Leonardo
git push --all bitbucket
phd
  • 82,685
  • 13
  • 120
  • 165
  • 7
    Could you please explain how your suggestion solves the original problem. Code only answers should generally be avoided. – Nigel Ren Oct 17 '17 at 18:42
0

This solved my issue Github "Updates were rejected because the remote contains work that you do not have"

git remote add origin [//your github url]

//pull those changes

git pull origin master 

// or optionally, 'git pull origin master --allow-unrelated-histories' if you have 
initialized repo in github and also committed locally

//now, push your work to your new repo

git push origin master
PauloBorba
  • 156
  • 3
  • 5