Local and Remote Repo not Synced

Hi there, I'm pretty new to GIT and Bitbucket and I have run into a problem because I'm new to this. My repo on bitbucket is not in sync with my local but when I'm trying to push my local repo to bitbucket it says everything is the same so nothing happens.

Everything was working fine until Git was telling me I couldn't push, being sure of what I thought was the solution I force pushed to bitbucket.

The force didn't do what I expected, on bitbucket I have 4 commits with the last one on the 13th of may. So by force pushing it didn't push my last commit but it somehow removed a few commits.
Locally I see 10 commits with the last one today. When I try to push it again it says there are no changed even though the commits are different and the code should be too.

I don't know exactly what I've done wrong an how I can solve this so that the commits I see locally are also on bitbucket.

Hope someone can help me with this,

Thanks in advance,

Joost 

1 answer

0 votes

Hi Joost!

Have all the files been staged and commited? You can get the status of your local repository and see how your local project is progressing in comparison to your Bitbucket repo. If there are any untracked files, that means that Git does not see them as part of a previous commit and thus, they'll be invisible for Bitbucket. To check the status you can use:

git status

If there are untracked files, you'll need to tell Git to track them. To do so use:

git add <file_name>

Now that all your files have been staged, you can commit them and then push using:

git push origin master

To learn more, please visit Copy your git repository and add files.

If get status was not showing any differences between your local repo and Bitbucket, please let us know so we can help you further.

Cheers!

Ana

Hi Ana,

Thanks for your help, I always use

git add .

to track my files, and as you suggested I tried

git status

but this is the reply

On branch master
nothing to commit, working tree clean

This is my local log in my phpstorm editor:
Schermafbeelding 2017-05-31 om 20.43.19.png

And these are my commits in bitbucket.Schermafbeelding 2017-05-31 om 20.42.51.pngAny idea on how to get them synced again?

Thanks!

Jim Redmond Atlassian Team May 31, 2017

All your recent commits are on Master, but you're pushing master. The capital M makes a big difference here.

Aha, and how do I solve this issue? Can i get rid of the double M/masters? And sync to bitbucket again? 

Jim Redmond Atlassian Team May 31, 2017

Based on the phpstorm snapshot, you should be able to do a fast-forward-only merge from Master into master, then push master and delete Master:

git checkout master
git merge --ff-only Master
git push origin master
git branch -d Master

Thanks Jim, when i try to merg it says:

Already up-to-date

So it seems the merge is not working. Sorry I feel a bit dumb to ask for everything but I'm a bit worried that when I try something I make a total mess of this :D.

 

Hello Ana or Jim,

 

Could you help me further with this problem I have? Merge doesn't seem to work. Hope one of you can help me.

Thanks,

Joost

Jim Redmond Atlassian Team Jun 05, 2017

Are the commits from big-M Master now available in small-m master on your local system? What about on Bitbucket?

No nothing was changed but I tried different stuff yesterday and got it solved.

I first reset my local repo to the point where my remote repo at bitbucket was at. I then added, committed and pushed everything from local to bitbucket.

Then on my own remote server I fetched, and reset --hard to get this one in sync aswell.

So everything is working perfectly now. Still don't know where the M-aster came from. I tried to reproduce it but that didn't work.

Well thanks a lot for all help!

Joost

 

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 06, 2018 in Bitbucket

Upgrade Best Practices

Hello! My name is Mark Askew and I am a Premier Support Engineer for products Bitbucket Server/Data Center, Fisheye & Crucible. Today, I want to bring the discussion that Jennifer, Matt, and ...

194 views 3 6
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you