##今天使用git push上传源代码的时候,出现了下面这个问题##
**error: failed to push some refs to 'https: //git hub.com anielLeefu/luckystar.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.md文件不在本地代码目录中,需要本地和远程的文件合并后才能上传本地的新文件
以下是两种解决方式:
方法一:
先拉下来 git pull origin master
然后再上传 git push -u origin master
如果没有解决,
方法二:
通过如下命令进行代码合并
git pull --rebase origin master
然后就可以push成功解决问题
注:如果没有设置origin,可以通过命令
git remote add origin +地址,之后就可以简化操作,使用git pull origin master和git push origin master 了