Git问题解决
2019-03-27 本文已影响0人
JillZsy
创建Git
- I don’t handle protocol 'git@https'
报错位置:git push
因为刚开始关联的仓库地址有误,重新关联
$ git remote rm origin
$ git remote add origin https://github.com/JillZsy/Flutter-jsDemo.git
- fatal: refusing to merge unrelated histories
报错位置:git pull origin master
由于git remote add之后,本地仓库和远程仓库实际上还是两个独立的仓库。如果用clone则不会有这个问题。
$ git pull origin master –allow-unrelated-histories
- git push error
由于没有先git pull就git push -u导致了本地文件与github上README.md冲突
$ git push -u origin master
To https://github.com/JillZsy/Flutter-jsDemo.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/JillZsy/Flutter-jsDemo.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
//此时远程库中README.md文件没有了,导致下面pull不成功
$ git pull origin master
From https://github.com/JillZsy/Flutter-jsDemo
* branch master -> FETCH_HEAD
fatal: refusing to merge unrelated histories
$ git pull origin master –allow-unrelated-histories
fatal: Couldn't find remote ref –allow-unrelated-histories
$ git push -u origin master
To https://github.com/JillZsy/Flutter-jsDemo.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/JillZsy/Flutter-jsDemo.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.
//最后强制提交成功
$ git push -u origin master -f