Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,299,229
Community Members
 
Community Events
165
Community Groups

Help with messed up repository (one remote, two local)

Edited

I am usually doing some basic code development on one PC (A) and pushing that to bitbucket via Sourcetree.

On my production computer (B), I pull this locally and typically mostly use the code as is, occasionally fixing a few bugs and pushing back to the Bitbucket repository.

Recently, I found myself in a situation where, while on (B), I pushed some modifications to Bitbucket, only to discover that I had some pending mods on (A) as well. I committed those on A locally and tried to push that to Bitbucket, which obviously failed.

I tried some uneducated actions: pulling the remote (as the error message was suggesting this) and some additional merge of some kind, which I stupidly did not note down.

The result is that I am finding myself in the situation described below (on A), which prevents me from pushing any further modifications made on A.

Is there any simple course of action to reconcile A and the remote so that I can the pull the result to B?

git problem.PNG

 

Edit: 

Actually, here is the error message I get when pushing the A repo to Bitbucket in SourceTree:

 

git -c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks push -v --set-upstream origin master:master
Pushing to https://bitbucket.org/XXXXXXXXXX.git
To https://bitbucket.org/XXXXXXXXXXX.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://bitbucket.org/XXXXXXXXXX.git'


hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and 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.

 

Completed with errors, see above.

1 answer

While I can't say that I have quite understood how this works, I managed to get out this hole by following some of the UI 's suggestions, ending up with this situation:

git probem solved.PNG

 

The lesson I draw from this is to always pull from remote before working on a repo and always push after having worked on a repo. Whichever machine you are working on. Sort of...

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Sourcetree

Bug Fix: Sourcetree for Windows authentication error when updating to app password

Hello Sourcetree users!!! With the recent removal of Bitbucket Cloud account passwords for app passwords (please see our Bitbucket Cloud community post for details on why we made this change for se...

62,258 views 127 27
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you