Q1.意想不到 git push -u origin master 会报错

本文解决了一个常见的GitHub问题:当尝试推送项目到远程仓库时遇到拒绝更新的错误。问题源于远程仓库与本地仓库不同步,特别是在远程仓库创建了本地未有的README.md文件。通过git pull --rebase origin master命令合并远程更改,再使用git push -u origin master完成推送。

一天,有勇气的想使用github新建项目,结果不顺畅,还好解决了

报错如下:

$ git push origin master
To github.com:smartBBer/LeetCode.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'git@github.com:smartBBer/LeetCode.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中的库不同步 

    嘻嘻:在创建远程创库时创建了README.md文件 ,本地库中没有

解决办法:

    使用git pull --rebase origin master合并 GitHub 和 本地 的库,本地会多出之前不同步的文件,在使用 git push -u origin master 推送到 GitHub 库中。

回顾具体操作过程截图如下:

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值