git push 报错的解决方案 ! [rejected] master -> master (fetch first)

1、楼主还是像平常一样快快乐乐得写完了代码,准备同步到git上面,

git add .

git commit -m "更新"

git push

然后就报错了,通过查阅资料发现报错原因是本地代码仓库和远程代码仓库不同步造成的。

2、报错信息:

 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://gitee.com/momojian/gophish.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.

3、解决办法:

同步本地仓库。

$ git pull --rebase https://github.com/XXX.git

上传最新代码。

git push -u origin master


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部