git push 时报错 error: failed to push some refs to 'git@xxxxxx'

原因:这是一个新建的一个仓库,提交到github时,没有 pull下来,导致 github中的README.md文件不在本地代码目录中

$ git push -u  origin master
To github.com:Houttuyniae/notes.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:Houttuyniae/notes.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.

需要先执行 git pull --rebase origin master 把  README.md 下来

$ git pull --rebase origin master
From github.com:Houttuyniae/notes
 * branch            master     -> FETCH_HEAD
First, rewinding head to replay your work on top of it...
如果在你pull之前,又执行了commit,提交了一次,则会报错

$ git pull --rebase origin master
error: cannot pull with rebase: You have unstaged changes.
error: additionally, your index contains uncommitted changes.
error: please commit or stash them.
需要先执行 git stash 缓存一下 最后在 push

$ git push -u  origin master
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 590 bytes | 590.00 KiB/s, done.
Total 5 (delta 3), reused 0 (delta 0)
remote: Resolving deltas: 100% (3/3), completed with 3 local objects.
To github.com:Houttuyniae/notes.git
   d81c6a9..929dc11  master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.




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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值