1. 程式人生 > >Git錯(五)

Git錯(五)

場景

從VCS中git中pull你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

類似資訊表pull成功

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,然後重新整理GitHub即可看到東西已成功推送。