2

I am a new developer and just began learning git and github. I have two repos on github, one to show the code for a project and then I made another so I could host the page to show off the project with github pages. I made a small change and pushed the commit to my original remote repo, and then tried to push the commit to the other repo and I keep getting this error:

Owner@MICHAEL-WORK-PC MINGW64 ~/Desktop/Coding/Dual N-Back Game Project (master|MERGING)
$ git push github master
To https://github.com/michaelacook/michaelacook.github.io
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/michaelacook/michaelacook.github.io'
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.

I have no idea why this is happening or how to fix it, I'm too new to git. Any suggestions? Thanks.

  • 2
    Possible duplicate of [rejected master -> master (non-fast-forward)](https://stackoverflow.com/questions/11696295/rejected-master-master-non-fast-forward) – orhtej2 Dec 08 '18 at 21:58
  • Did you read the error message and the hint? It even tells you which command you should use. – alfunx Dec 08 '18 at 21:59
  • I did read it, and I did perform a pull before trying again. Same message. Should have specified that in my question, sorry. – Michael Alexander Dec 08 '18 at 22:00
  • https://stackoverflow.com/search?q=%5Bgit%5D+hint%3A+Updates+were+rejected+because+the+tip+of+your+current+branch+is+behind – phd Dec 08 '18 at 22:00

1 Answers1

3

You must pull before you push.

You have changes in your remote repository which does not exist in your local and you must pull them and perform a merge.

# pull changes
git pull origin master

# if you have a conflicts resolve them and ad your files
git add .

# commit your resolution
git commit 


# now you can push your changes
git push origin master
CodeWizard
  • 128,036
  • 21
  • 144
  • 167