Git问题解决

2019-03-27  本文已影响0人  JillZsy

创建Git

报错位置:git push
因为刚开始关联的仓库地址有误,重新关联

$ git remote rm origin
$ git remote add origin https://github.com/JillZsy/Flutter-jsDemo.git

报错位置:git pull origin master
由于git remote add之后,本地仓库和远程仓库实际上还是两个独立的仓库。如果用clone则不会有这个问题。

$ git pull origin master –allow-unrelated-histories
$ 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
上一篇 下一篇

猜你喜欢

热点阅读