0

So I am creating a simple tetris game and I am trying to push my changes to GitHub. I created the repo through the Github site, I can add and commit my changes, but I cannot push to master. Does anybody know why? This is the message I get in my terminal:

    ~/Desktop/xxxxxxxx/tetris$ git push -u origin master
    To https://github.com/xxxxx/TetrisReact
     ! [rejected]        master -> master (non-fast-forward)
    error: failed to push some refs to 'https://github.com/xxxxx/TetrisReact'
    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.
csb00
  • 1,091
  • 2
  • 18
  • 36
  • https://stackoverflow.com/search?q=%5Bgit%5D+hint%3A+Updates+were+rejected+because+the+tip+of+your+current+branch+is+behind – phd Nov 07 '19 at 02:36

1 Answers1

0

Because your local git and remote git is different. So you have 2 solutions:

1) Merge your local git with remote git (safe way). Any change in your local and remote git will merge together. Sometimes, it will have some conflicts, you must fix them before pushing it to remote git.

git pull origin master 

2) Push with ignore changes in remote git (unsafe way). -f option tell git force replace your remote git by your local git.

git push origin master -f 
Hay Trần
  • 564
  • 4
  • 22