初始化的git项目,在托管平台创建项目,并生成项目基本信息,如果 .gitignore 文件
此时本地项目代码也有此文件,在执行git push -u origin master的时候,报如下错误信息
Push to origin/master was rejected
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.
原因:本地项目代码和托管平台上有代码冲突,可以先用git pull拉取下来更新,如果不行,
把托管平台的冲突文件.gitignore文件暂时先删除,即可提交成功。然后把不需要添加到版本控制
的文件,再次加到.gitignore文件并提交推送。