首先要參照http://my.oschina.net/dxqr/blog/134811?p=2#comments
git
我每次第一次提交的時候都會遇到這個問題fetch
第一次次將現有的項目提交到git上面會遇到這個問題。
$ git remote add test http://git.oschina.net/liangzhenghui/gitTest.git
Administrator@KEN /g/code/gitTest/HelloWorld (master)
$ git push test master
Username for 'http://git.oschina.net': liangzhenghui
Password for 'http://liangzhenghui@git.oschina.net':
To http://git.oschina.net/liangzhenghui/gitTest.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'http://git.oschina.net/liangzhenghui/gitTest
.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 merge the remote changes (e.g.,
hint: 'git pull') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.ui
而後能夠按照osc上朋友的方法這樣解決:.net
先, git pull origin master
再 git push origin master
code