Git首次push报错

$ git push -u origin master
To git@github.com:xxx/xxx.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'git@github.com:xxx/xxx.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.

初始化git后push到github错误提示


原因:没有添加 readme.txt


解决方法:

方法1、在github的工程内,手动添加README.txt,本地分支内pull最新

方法2、在本地vim一个新的readme.txt文件,填入内容,commit后再次 push到github


附加:


也有可能是远程仓库 添加了新文件,本地不是最新的远程仓库版本号

需要先拉去 远程仓库到本地


git pull --rebase


or 

git pull <remote> <branch> --rebase //<branch> 可以不用如果没有


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
回答: 当执行git push命令时,可能会遇到不同的报错。其中,一种报错是“fatal: remote error: You can’t push to 目标地址 Use 目标地址”\[1\],这通常是由于目标地址不正确导致的。另一种报错是“fatal: unable to access 目标地址: Failed connect to github.com:443; Connection timed out”\[2\],这可能是由于网络连接超时导致的。还有一种报错是“error: failed to push some refs to 'git@xxx.xx.git’”\[3\],这通常是由于多人开发时出现代码冲突导致的。解决这些问题的方法包括检查目标地址是否正确、检查网络连接是否正常以及解决代码冲突等。 #### 引用[.reference_title] - *1* *2* [【经验分享】git push 时出现的三种报错及解决方案](https://blog.csdn.net/Sunnyside_/article/details/118358214)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [git push 报错failed to push some refs to‘xxx](https://blog.csdn.net/weixin_45811256/article/details/125989719)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值