使用git 错误解决hint: Updates were rejected because the tip of your current branch is behind

错误

root@iZ94orvma5bZ mshop]# git push origin master
To git@github.com:DanceHill/mshop.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to ‘git@github.com:DanceHill/mshop.git’
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. ‘git pull’)
hint: before pushing again.
hint: See the ‘Note about fast-forwards’ in ‘git push –help’ for details.

 

这个是因为本地版本低于服务器版本,比如你在git网页上修改了文件,而又没有 pull,然后直接修改本地文件,你提交的时候就会报这个错误

解决:

[root@iZ94orvma5bZ mshop]# git push -u origin master -f
Counting objects: 98, done.
Compressing objects: 100% (57/57), done.
Writing objects: 100% (60/60), 57.39 KiB | 0 bytes/s, done.
Total 60 (delta 36), reused 0 (delta 0)
remote: Resolving deltas: 100% (36/36), completed with 31 local objects.
To git@github.asdfddff/mvshop.git
+ bb60a15...291193d master -> master (forced update)
Branch master set up to track remote branch master from origin.

 

发表评论