Py学习  »  Git

无法将更改推送到GitHub

csb00 • 4 年前 • 287 次点击  

因此,我正在创建一个简单的俄罗斯方块游戏,并试图将我的更改推到GitHub我通过Github站点创建了repo,我可以添加和提交我的更改,但是我不能向master推送有人知道为什么吗这是我在终端收到的信息:

    ~/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.
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/49219
 
287 次点击  
文章 [ 1 ]  |  最新文章 4 年前
Hay Trần
Reply   •   1 楼
Hay Trần    4 年前

因为本地git和远程git不同所以你有两个解决方案:

1)将本地git与远程git合并(安全方式)本地和远程git中的任何更改都将合并在一起有时,它会有一些冲突,您必须在将其推送到远程git之前修复它们。

git pull origin master 

2)在远程git中使用忽略更改的Push(不安全的方式)。 -f 选项告诉git force用本地git替换远程git。

git push origin master -f