Git远端仓库被不同版本的本地仓库push,不能正常提交代码


$ git push
Username for 'https://github.com': Grand2015
To https://github.com/Grand2015/Leakage-simulation.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/Grand2015/Leakage-simulation.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.


关键部分简单翻译一下:
错误:无法推一些参考“https://github.com/Grand2015/Leakage-simulation.git”
提示:更新被拒绝,因为远程包含您没有本地的工作。 
这通常是由另一个存储库推送到同一个引用引起的。
您可能希望首先集成远程更改(例如,“git pull ...”),然后再次推送。
有关详细信息,请参阅“git push --help”中的“关于快进的注意事项”。
原因很明了,git远端仓库被不同版本的本地仓库push了,解决这个问题先要对本地仓库与远端仓库进行合并,
执行指令: git pull origin master 会出现对话框让你输入融合的理由
i 开始输入 
esc:wq保存退出


$ git pull origin master
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (1/1), done.
remote: Total 3 (delta 1), reused 3 (delta 1), pack-reused 0
Unpacking objects: 100% (3/3), done.
From https://github.com/Grand2015/Leakage-simulation
 * branch            master     -> FETCH_HEAD
   b31ecb7..ed39b19  master     -> origin/master
Merge made by the 'recursive' strategy.
 README.md | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

     
     

融合完成,接着提交数据

$ git push
Username for 'https://github.com': Grand2015
Counting objects: 20, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (20/20), done.
Writing objects: 100% (20/20), 63.56 KiB | 0 bytes/s, done.
Total 20 (delta 14), reused 0 (delta 0)
remote: Resolving deltas: 100% (14/14), completed with 5 local objects.
To https://github.com/Grand2015/Leakage-simulation.git
   ed39b19..bd61e7b  master -> master

成功提交代码




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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值