Git错(五)

Git错(五)

场景

VCS中git拉取GitHub初始化空仓库,VCS->Git->pull报错

Push rejected: Push to origin/master was rejected

Git Pull Failed: fatal: refusing to merge unrelated histories

分析

git拒合两不相干历史。

解决

工程文件夹打开Git Bash执行

git pull origin master --allow-unrelated-histories

如下拉取成功

From https://github.com/danishlyy/HappyBirthday
 * branch            master     -> FETCH_HEAD
Merge made by the 'recursive' strategy.
 README.md | 2 ++
 1 file changed, 2 insertions(+)
 create mode 100644 README.md

然后git status查当前仓库全部add且commit否,是则git push -u origin master推本地仓库至GitHub。