1

The master branch in my local repo is showing a push badge with increasing numbers. I know it is up-to-date with the remote master, because all changes in local branches have been pulled and merged into the remote master. But every time I fetch and pull from the remote to update my local repo, the local master appears to be ahead of the remote by one more commit. But I know the two masters are identical.

(not sure how all this started, I may have done a forced push to the origin, at somepoint...?)

Would 'git pull --rebase origin master' help get the local master match the remote? Or would it it be git reset --hard remote/master ?

And how could I avoid the two branches getting out of sync again?

alfavictor
  • 63
  • 9
  • Actually, `git pull --rebase` would _cause_ the observations you are seeing, namely that your local `master` appears to be some number of commits ahead of the remote. You might want to include the exact steps which are happening here. – Tim Biegeleisen Sep 04 '20 at 10:34
  • Does a `git pull` create a merge commit locally? This could explain the extra commit your seeing. This is often seen when working together on the same branch without rebase pulling. – naeramarth7 Sep 04 '20 at 12:07
  • Every time I make changes to one of the local branches, I pull it to the corresponding remote branch and and merge it to the remote master. Then I do a fetch in the local repo, which then shows that a pull is needed by the local master to get the change from the remote master. I've not been doing local merges. – alfavictor Sep 07 '20 at 08:11

1 Answers1

0

Check if git config pull.rebase is set to true, as I mentioned here.

That would means any git pull would actually replay your un-pushed local commits on top of the updated remote origin/master tracking branch.
If the local history seems correct, a simple git push should resolve the issue.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • The local and remote masters are the same. When I try to push the local master to the remote, I get an a message that looks like a text picture of guy in sunglasses and this: "remote: Branch refs/heads/master can only be modified through pull requests. remote: Check your branch permissions configuration with the project administrator." – alfavictor Sep 07 '20 at 08:31
  • @alfavictor Are you pushing to gitHub, GitLab? BitBucket? An on-premise instance, or a .com service? – VonC Sep 07 '20 at 09:02
  • I'm pushing to BitBucket – alfavictor Sep 07 '20 at 10:32