參考文獻
1.http://www.linuxidc.com/Linux/2012-04/58985.htm
2.http://ihower.tw/blog/archives/2620
3.http://hi.baidu.com/lettoo/blog/item/e2e7f30fec72bdf6ab645789.html
正文
學習使用git,可以參考文獻3,但是在操作的最后一步,也就是想將代碼上傳到git中去的時候,出現如下錯誤:
Pushing to git@github.com:xwdreamer/FirstRepo_xuwei.git
To git@github.com:xwdreamer/FirstRepo_xuwei.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:xwdreamer/FirstRepo_xuwei.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
在網上查了也一些資料,見參考1中的內容,知道是因為git中的內容與本地中的內容部一直,需要先fetch,然后再merge,最后上傳push。但是不會操作,后面又說可以通過強制push來完成,見下圖所示:
勾選強制覆蓋已有的分支(可能會丟失改動),再點擊上傳,上傳成功。