-2

I am the only user of this remote git repository. And I work only on one machine.

I avoid git command line and do "Commit all" and "Push" in vscode. No other interaction with git.

And still I now get this. I suspect something went wrong because of network trouble. But since my git fu is extremely weak I am very hesitating to test the suggested action here. (I mean the data must be wrong somewhere.)

Ah, and this is on Windows 10. Maybe some special problem there?

And. vscode is in my opinion very buggy (but comfortable for me right now). Big problems with race conditions in the editor for me. (Using a cheap laptop.) So if I do a pull I will have to check everything very carefully.

What can I safely do?

> git push origin master:master
To bitbucket.org:HIDDEN.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'bitbucket.org:HIDDEN.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.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Leo
  • 4,136
  • 6
  • 48
  • 72
  • 1
    You can do `git log master` and `git log origin/master` (maybe do `git fetch` first) to see what commits are at the respective branches. – Felix Kling Sep 06 '20 at 16:07
  • 2
    `git log --all --decorate --graph --oneline` is a good way to visualize the branches together. – chepner Sep 06 '20 at 16:09
  • @chepner That was a useful one. I can see now where it went wrong. Same commit time etc, but different id:s. Though I have no idea yet how to proceed. – Leo Sep 06 '20 at 23:39
  • Hm, looks like I want to use "git revert" on the server? Is that correct? How do I do it? And can I just do a new "push" from my laptop after that? – Leo Sep 06 '20 at 23:43

2 Answers2

2

update your local branch with master branch

use

git rebase origin/master

If any merge conflict occurs resolve it. if not then you are lucky :).

Dashrath Mundkar
  • 7,956
  • 2
  • 28
  • 42
2

What can I safely do?

Gather more information.

To find out what's going on, say git fetch. Now git log origin/master and also git log master, and you will see what commit origin/master has (reflecting the remote) that your local master does not.

From there, you can decide what to do.

matt
  • 515,959
  • 87
  • 875
  • 1,141