問題描述
- 在github建立了項目
- 本地已經(jīng)存在了一個項目,所以就沒有從github clone空項目 直接在本地使用了git init
- 建立連接 git remote add origin *****此處是github上的項目地址
- 然后 直接 git add ; git commit 了
- 然后 就 git push origin master 于是就出現(xiàn)了下面的問題
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/*****.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.
github上的版本里有readme文件和本地版本沖突,
解決方案是:強制覆蓋已有的分支
使用git push -u origin master -f
搞定。
正確的做法是
在第3步建立了聯(lián)系之后,使用git pull -f --all
或者中規(guī)中矩,不要在本地git init 在github上clone之后 把原來的項目 移動過去就好了。