git - error: failed to push some refs to 'https://github.com/Tate-zwt/WTMicroblog.git'' 解决办法

 

在使用git的时候, 我用git commit --amend 命令修改了上一个提交的一些内容, 而上一个提交的内容已经被我用push推到远程服务器了, 现在我用git push -u origin master 推送 amend之后的提交, 推送失败了, 并给出了错误提示如下:

 

To https://github.com/Tate-zwt/WTMicroblog.git

 ! [rejected]        master -> master (fetch first)

error: failed to push some refs to 'https://github.com/Tate-zwt/WTMicroblog.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.

 


上网搜了一下, 在stackoverflow上找到了解决办法, 是用 -f 参数 来push: git push -f origin master.stackoverflow真是一个好网站, 就像一个程序员百科全书一样, 基本上所有的问题都能在上面找到, 你还能贴出你遇到的问题, 让里面的大神帮忙解决, 解决问题的速度都很快, 起码我看到的都是半个小时以内就有人回复了, 强烈推荐.

 

参考: http://stackoverflow.com/questions/3598355/i-am-not-able-to-push-on-git

         https://www.kernel.org/pub/software/scm/git/docs/git-push.html#_note_about_fast_forwards

 

 

posted @ 2015-03-31 19:42  糖醋排骨_zwt  阅读(3444)  评论(1编辑  收藏  举报