初次Push代码到Github报错

489 阅读1分钟

问题描述

  1. 初次本地代码上传到Github的时候,执行git push -u origin master命令报错。
  2. 错误详情
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/TTmrxb/TTPlayer.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.

问题原因

Github远程分支有文件没有合并到本地,如README文件等。

解决方法

  1. 执行git pull --rebase origin master命令
  2. 然后推送上传git push -u origin master