*問題描述
今天建的一個工作日志文檔,推送遠程倉庫不成功。
*過程描述
1.git init
2.git remote add origin https://gitee.com/tylerGuo1/dailyRecord.git
遠程倉庫不是使用ssh,竟然不報錯,看來http和ssh兩者效果一樣。
3.git add -A
4.git commit -m "初始化"
5.git push
報錯如下:
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin master
6.git push -u origin master
提示需要先拉去,報錯如下:
To https://gitee.com/tylerGuo1/dailyRecord.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://gitee.com/tylerGuo1/dailyRecord.gi
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.
7.git pull origin master
報錯如下:
* branch master -> FETCH_HEAD
fatal: refusing to merge unrelated histories
8.git pull origin master -allow-unrelated-histories
報錯如下:
fatal: couldn't find remote ref –allow-unrelated-histories
9.git pull origin master --allow-unrelated-histories //成功。
一直卡在問題8,后來發現是小了一個短杠,但其實中間有一次試錯的時候用了兩個短杠,后來又用就可以了。