git 远程与本地不一致导致的报错
anlondon Lv6

报错信息:
error:failed to push some refs to …
Dealing with “non-fast-forward” errors
From time to time you may encounter this error while pushing:
$ git push origin master
To ../remote/

! [rejected] master -> master (non-fast forward)

error: failed to push some refs to ‘../remote/‘
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again. See the ‘non-fast forward’
section of ‘git push –help’ for details.

原因

是因为远程与本地不一致导致的
解决步骤:

  1. 需要先拉取远程的
  2. 再手动合并冲突文件
  3. 提交修改
  4. 提交到远程
1
2
3
4
5
6
7
8
9
$git pull origin

$git merge origin master
//可能提示需要手动合并的文件,根据路径修改保留需要的内容即可

$git add .
$git commit -m 'dev| merge error file'

$git push origin

参考资料:

 Comments