git did not exit cleanly (exit code 1) 的解决办法

问题描述:

关于Git的使用,在通常情况下,习惯于先在本地创建一个本地仓库,然后将项目提交到本地master,再将本地master中的项目Push 到远程仓库中,这样问题就来了。

具体错误信息如下:

git.exe push --progress "origin" master To https://github.com/Jackson-AndyLau/CMSManager.git ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to https://github.com/Jackson-AndyLau/CMSManager.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 did not exit cleanly (exit code 1) (12359 ms @ 2018-07-01 09:41:24)

如下图所示:

解决办法:

关于这个问题,在网上搜罗了一下,很多工程师都遇到过,解决方法也是五花八门,要不删除一些文件,要不修改一些配置文件,但最终还是未能解决问题。

后来经过多次的尝试,终于找到了解决办法,这儿分享出来,希望能帮助到你,能少花费些时间去看那些无用的方法!!!

1、根据错误内容提示,先将远程新建的空仓库 “ Clone ” 到本地,会得到一个空的与远程仓库对应的目录,如下图:

2、然后将文件提交到master,再Push到远程仓库,发现问题解决了额, 如下图:

再看远程仓库:

经验分享 程序员 微信小程序 职场和发展