github:error: 无法推送一些引用到

git push -u origin master //会提示输入用户名和密码

输入完之后会出现以下错误:

Username for ‘https://github.com’: DylanLN
Password for ‘https://DylanLN@github.com’:
To https://github.com/DylanLN/oryxbot_ws-ros2
! [rejected] master -> master (non-fast-forward)
error: 无法推送一些引用到 ‘https://github.com/DylanLN/oryxbot_ws-ros2’
提示:更新被拒绝,因为您当前分支的最新提交落后于其对应的远程分支。
提示:再次推送前,先与远程变更合并(如 ‘git pull …’)。详见
提示:‘git push --help’ 中的 ‘Note about fast-forwards’ 小节。

然后输入

git fetch

git merge//会出现错误: fatel: 未指定提交并且 merge.defaultToUpstream 未设置。

此时需要重新git add ,git commit

然后执行

git push -u origin master

会出现以下错误:

! [rejected] master -> master (non-fast-forward)

error: 无法推送一些引用到 ‘https://github.com/xxxxx/xxx.git’

提示:更新被拒绝,因为您当前分支的最新提交落后于其对应的远程分支。

提示:再次推送前,先与远程变更合并(如 ‘git pull’)。详见

提示:‘git push --help’ 中的 ‘Note about fast-forwards’ 小节。

执行:


git config branch.master.remote origin

git config branch.master.merge refs/heads/master

git pull

​Merge made by the ‘recursive’ strategy.

README.md | 4 ++++

1 file changed, 4 insertions(+)

git add hello.txt

git commit -m "second push"

无文件要提交,干净的工作区


git push -u origin master

代码即可同步成功!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值