failed to push

当尝试推送Git更新时遇到'failed to push some refs'错误,原因是远程仓库有新的改动。解决方法是先使用'git pull --rebase'合并远程更改,然后再执行'git push',确保本地和远程仓库同步。
摘要由CSDN通过智能技术生成

failed to push some refs to ‘’

问题描述:

summerice@summerice-ubuntu:~/MyNote$ git push
To github.com:My-Summerice/myNote.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'git@github.com:My-Summerice/myNote.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.

解决办法:

  • 分析出现该问题的原因是因为远程仓库的文件出现了改动,所以需要先将远程仓库合并到本地仓库,再进行push。
// 1.合并
summerice@summerice-ubuntu:~/MyNote$ git pull --rebase
remote: Enumerating objects: 8, done.
remote: Counting objects: 100% (8/8), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 6 (delta 2), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (6/6), done.
From github.com:My-Summerice/myNote
   0cb6b54..7e96a3f  master     -> origin/master
First, rewinding head to replay your work on top of it...
Applying: update
// 2.推送
summerice@summerice-ubuntu:~/MyNote$ git push
Counting objects: 5, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 551 bytes | 551.00 KiB/s, done.
Total 5 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To github.com:My-Summerice/myNote.git
   7e96a3f..097db1a  master -> master
  • 成功!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值