解决本地amend后,远程服务器拒绝push请求的问题
Contents
文章来源 www.kowen.cn
今天写程序时遇到一个问题,提交代码到远程服务器时遭到了拒绝,报错如下:12345678$ git push origin restructTo ssh://git@kowen.cn:9022/IcCard.git ! [rejected] restruct -> restruct (non-fast-forward)error: failed to push some refs to 'ssh://git@kowen.cn:9022/IcCard.git'hint: Updates were rejected because the tip of your current branch is behindhint: 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.
后来分析了一下,原因是我刚刚push了restruct分支到服务器,但是我代码有个地方忘了改了,改完之后使用的 git commit –amend 命令在本地提交了修改,造成了本地的最新版本和远端最新版本的不一致。 于是按照提示先运行了 git pull origin restruct , 然后再次push成功.