用Eclipse给github提交代码,提示rejected - non-fast-forward错误的解决办法

版权声明:转载请注明出处 https://blog.csdn.net/yrwan95/article/details/81466302

错误原因

出现 rejected - non-fast-forward 错误,是由于本地Repository和远程Repository中的文件出现冲突,原因之一便是待push的代码在远端发生改变导致本地和远程文件个数不同(例如在github上手动修改README.md后)。

解决办法

1.打开 Git Repositories页面(打开Windows - Show View - Others,在弹出的对话框中选择Git Repositories即可),确保在Git Repositories 中可以看到待push的工程;

2.在工程的 Remotes 上右键单击打开Create Remotes进行下一步,Create Remotes后即可在Remotes中看到远端,在分支下的绿色箭头图标代表Fetch,右键单击打开Configure Fetch;

3.确认 URI 和 Ref mappings(如果为空,点击Advanced进行配置,如图)都是正确的,点击 Save and Fetch;

4.此时在 Branches 中可以看到 Remote Tracking 存在远端分支;

5.右键 Branches 中的 Local 中的 master,选择 Merge ,选择 Remote Tracking 中的 origin/master,点击 Merge;

6.重新push代码即可。

猜你喜欢

转载自blog.csdn.net/yrwan95/article/details/81466302
今日推荐