学无先后,达者为师

网站首页 编程语言 正文

Git:解决Git向码云中push文件报错:! [rejected] master -> master (fetch first)

作者:KaiSarH 更新时间: 2022-04-12 编程语言

最近项目开发用到git,导师使用的是码云。
在Windows环境中使用Git连接码云,尝试push文件时报错:

*! [rejected] master -> master (fetch first)
error: failed to push some refs to ‘git@gitee.com:huankai7/practice.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.

如图:
在这里插入图片描述
找了很多方法都是针对github的,最后找到一句命令行

$ git pull gitee master --allow-unrelated-histories
在这里插入图片描述
执行后成功上传。
在这里插入图片描述

原文链接:https://kaisarh.blog.csdn.net/article/details/102565536

栏目分类
最近更新