git push 失败与解决方法

今天想把最近的一些小代码push到github上
我先是将该目录git init进行初始化,然后
git add -A ,
接着
git commit -m “description...”
然后在github上新建一个远程库,想要将其与我本地的库相关联,使用:
git remote add origin git@github.com:YOURGITHUBNAME/REPOSITORY.git
并push到远程端
至此,一切顺利

于是,我使用了命令:
git push -u origin master
结果报错如下:
error: failed to push some refs to 'git@github.com:你的远程库名.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
从提示可以看出,是由于两者不同步,因此需要先pull,进行合并然后在进行push,
因此先使用
git pull --rebase origin master
将远程文件同步下来。
然后再执行推送
git push -u origin master
终于,成功!


  • 14
    点赞
  • 41
    收藏
    觉得还不错? 一键收藏
  • 10
    评论
评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值