如何解决git====push 过程中出现的。error: failed to push some refs

当我们在利用git  push 文件到仓库时出现了一下问题:

! [rejected] master -> master (fetch first)
error: failed to push some refs to 'git@github.com:yaogengzhu/ajax.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.

 

 

解决办法:

1.强制上传  git push  -f  //git仓库地址   master    (但是经过的测试 ,这个办法好像会覆盖掉仓库的文件!谨慎使用!

2.方法二:a)可以通过如下命令进行代码合并  git  pull --rebase //仓库地址  master      

     b) 然后 通过 git  push  //仓库地址  master         (办法可以成功的push 文件!且仓库文件不受影响!建议使用

 

 

目前我掌握就这两个方法~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

 

posted @ 2018-10-28 19:43  yaogengzhu  阅读(939)  评论(0编辑  收藏  举报