0

So basically for whatever reason after merging my master branch with another branch and pushing master branch to github repo my code was filled with <<<<<<< HEAD for whatever reason, even in places that I edited many commits ago so what I did was git reset --hard to the previous commit and that fixed the code now when I try to push my master branch to github repo I get

 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'my github repo'
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.

now doing git pull would just give me the code that's filled <<<<<<HEAD which I don't need. So I looked for some solutions and the first few results suggested git push -f origin branch but when I do that I get

error: src refspec branch does not match any.
error: failed to push some refs to my github repo

so what should I do now, lads?

Kris
  • 3
  • 1
  • 3

2 Answers2

0
git push github master
To git@github.com:Joey-project/project.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:Joey-project/project.git'

is an often reoccuring error.

I've read that one of the solutions is to use a variation of the following commands:

git fetch github; git merge github/master

May I suggest you to also look at Git non-fast-forward updates were rejected Merge the remote changes, it has a lot of extra information..

Community
  • 1
  • 1
Joey Dorrani
  • 371
  • 1
  • 1
0

found it myself

git push origin HEAD --force

does the trick.

Kris
  • 3
  • 1
  • 3