github中non-fast-forward错误的解决

参考文献

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来完成,见下图所示:

勾选强制覆盖已有的分支(可能会丢失改动),再点击上传,上传成功。

posted @ 2012-05-29 14:43  xwdreamer  阅读(71875)  评论(5编辑  收藏  举报