使用git push时报错怎么处理
本篇内容主要讲解“使用git push时报错怎么处理”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“使用git push时报错怎么处理”吧!
[root@361wayshell]#gitpushwarning:push.defaultisunset;itsimplicitvalueischanginginGit2.0from'matching'to'simple'.Tosquelchthismessageandmaintainthecurrentbehaviorafterthedefaultchanges,use:gitconfig--globalpush.defaultmatchingTosquelchthismessageandadoptthenewbehaviornow,use:gitconfig--globalpush.defaultsimpleSee'githelpconfig'andsearchfor'push.default'forfurtherinformation.(the'simple'modewasintroducedinGit1.7.11.Usethesimilarmode'current'insteadof'simple'ifyousometimesuseolderversionsofGit)
放”狗”查询后,得知‘matching’ 参数是 Git 1.x 的默认行为,其意是如果你执行 git push 但没有指定分支,它将 push 所有你本地的分支到远程仓库中对应匹配的分支。而 Git 2.x 默认的是 simple,意味着执行 git push 没有指定分支时,只有当前分支会被 push 到你使用 git pull 获取的代码。键入如下命令:
[root@361wayshell]#gitconfig--globalpush.defaultmatching错误二:
[root@361wayshell]#gitpush-uoriginmasterTohttps://361way:mypassword@github.com/361way/shell.git![rejected]master->master(fetchfirst)error:failedtopushsomerefsto'https://361way:mypassword@github.com/361way/shell.git'hint:Updateswererejectedbecausetheremotecontainsworkthatyoudohint:nothavelocally.Thisisusuallycausedbyanotherrepositorypushinghint:tothesameref.Youmaywanttofirstmergetheremotechanges(e.g.,hint:'gitpull')beforepushingagain.hint:Seethe'Noteaboutfast-forwards'in'gitpush--help'fordetails.
再次push,发现又有报错,根据报错内容,大致了解的情况是,本地和远端的内容可能不一致,建议git pull 一份,再push到romte 。由于平时有些修改会在阿里云服务器上修改过的懒得push到远端同步,所以本地和远端的不一致也是有可能的。即然不一致,以阿里云上保存的为准吧,强制同步下。
[root@361wayshell]#gitpush-uoriginmaster--force
强制同步,发现可以正常同步内容到github上,而且后面再加文件进行同步,发现也未出现报错了。
到此,相信大家对“使用git push时报错怎么处理”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。