{"id":538,"date":"2020-03-01T21:44:36","date_gmt":"2020-03-01T13:44:36","guid":{"rendered":"https:\/\/www.caiqinyi.cn\/?p=538"},"modified":"2025-02-26T11:31:10","modified_gmt":"2025-02-26T03:31:10","slug":"gitlab_push_error","status":"publish","type":"post","link":"https:\/\/www.caiqinyi.cn\/index.php\/2020\/03\/01\/gitlab_push_error\/","title":{"rendered":"GitLab\u8bd5\u6c34,\u89e3\u51b3push error"},"content":{"rendered":"<p>\u5373\u5c06\u63d0\u4ea4\u6bd5\u4e1a\u8bba\u6587(03.12)\u4e86, \u65f6\u95f4\u6709\u70b9\u7d27, \u8001\u677f\u5408\u4f5c\u7684\u516c\u53f8\u90a3\u8fb9\u53c8\u540c\u65f6\u9700\u8981\u5e72\u6d3b, \u771f\u662f\u5fc3\u529b\u4ea4\u7601, \u53cd\u6b63\u53ea\u80fd\u5148\u628a\u9505\u7529\u7ed9\u5e08\u5f1f\u4eec\u4e86\u563f\u563f(\u9003~)<\/p>\n<p>\u7531\u4e8eGitHub\u7684\u79c1\u6709\u4ed3\u5e93\u7684\u5f00\u53d1\u8005\u6700\u591a\u53ea\u80fd\u9080\u8bf7\u4e09\u4e2a, \u800cGitLab\u8c8c\u4f3c\u6ca1\u8fd9\u9650\u5236, \u56e0\u6b64\u6b64\u6b21\u4fbf\u5148\u8f6c\u6218GitLab\u8bd5\u6c34, \u64cd\u4f5c\u8d77\u6765\u4e0d\u5927\u719f\u6089, push\u4ee3\u7801\u7684\u65f6\u5019\u51fa\u4e86\u70b9\u95ee\u9898\u2026\u2026<\/p>\n<p><!--more--><\/p>\n<p><strong>\u53c2\u8003\u6750\u6599<\/strong><br \/>\n1. <a href=\"https:\/\/gitbook.tw\/chapters\/github\/fail-to-push.html\">\u3010\u72c0\u6cc1\u984c\u3011\u600e\u9ebc\u6709\u6642\u5019\u63a8\u4e0d\u4e0a\u53bb\u2026<\/a><br \/>\n2. <a href=\"https:\/\/github.com\/LeachZhou\/blog\/issues\/11\">Gitlab\u5f3a\u5236\u63a8\u9001\u63d0\u793a&#8221;You are not allowed to force push code to a protected branch on this project.&#8221;<\/a><\/p>\n<p>\u4e3b\u8981\u78b0\u5230\u4e24\u4e2a\u95ee\u9898.<\/p>\n<p>1. <\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"C++\" data-enlighter-theme=\"monokai\">\r\nhint: Updates were rejected because the remote contains work that you do\r\nhint: not have locally. This is usually caused by another repository pushing\r\nhint: to the same ref. You may want to first integrate the remote changes\r\nhint: (e.g., 'git pull ...') before pushing again.\r\nhint: See the 'Note about fast-forwards' in 'git push --help' for details.\r\n<\/pre>\n<p>\u8fd9\u6bb5\u8baf\u606f\u8fdc\u7aef\u4ee3\u7801\u7684\u7248\u672c\u8981\u9ad8\u4e8e\u672c\u5730\u7248\u672c, \u6240\u4ee5Git\u963b\u6b62\u4f60\u8fdb\u884c\u66f4\u65b0. \u89e3\u6c7a\u65b9\u6cd5\u7b97\u662f\u6709\u4e24\u62db.<\/p>\n<p><strong>\u7b2c\u4e00\u62db:\u5148\u62c9\u518d\u63a8<\/strong><br \/>\n\u56e0\u4e3a\u672c\u5730\u7684\u4ee3\u7801\u662f\u6bd4\u8f03\u65e7\u7684, \u6240\u4ee5\u5e94\u8be5\u5148\u62c9\u4e00\u4efd\u8fdc\u7aef\u7684\u4ee3\u7801\u56de\u4f86\u66f4\u65b0, \u7136\u540e\u518d\u63a8\u4e00\u6b21, \u5373<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"C++\" data-enlighter-theme=\"monokai\">\r\ngit pull --rebase\r\n<\/pre>\n<p>\u8fd9\u91cc\u52a0\u4e86&#8211;rebase\u53c2\u6570\u662f\u8868\u793a\u4ee3\u7801pull\u4e0b\u4f86\u4e4b\u540e\u8bf7\u4f7f\u7528Rebase\u65b9\u5f0f\u8fdb\u884c\u5408\u5e76, \u5f53\u7136\u60f3\u7528\u4e00\u822c\u7684\u5408\u5e76\u65b9\u5f0f\u4e5f\u6c92\u95ee\u9898. \u5408\u5e76\u65f6\u5982\u679c\u6c92\u53d1\u751f\u51b2\u7a81, \u63a5\u8457\u5e94\u8be5\u5c31\u53ef\u4ee5\u987a\u5229\u5f80\u4e0apush\u4e86.<\/p>\n<p><strong>\u7b2c\u4e8c\u62db:\u65e0\u89c6\u89c4\u5219, \u603b\u4e4b\u5c31\u662f\u542c\u6211\u7684!(\u5927\u96fe~\u9738\u9053\u603b\u88c1\u8303~)<\/strong><br \/>\n\u52a0\u4e0a\u4e86&#8211;force\u6216\u662f-f\u53c2\u6570, \u5b83\u5c31\u6703\u5f3a\u8feb\u786c\u63a8\u4e0a\u53bb, \u628a\u4e4b\u524d\u7684\u5167\u5bb9\u8986\u76d6\u6389, \u5373<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"C++\" data-enlighter-theme=\"monokai\">\r\ngit push -f\r\n<\/pre>\n<p>2. Gitlab\u5f3a\u5236\u63a8\u9001\u63d0\u793a&#8221;You are not allowed to force push code to a protected branch on this project.&#8221;<\/p>\n<p>GitLab\u6709\u53d7\u4fdd\u62a4\u7684\u5206\u652f\u4e00\u8bf4, \u5373\u88ab\u4fdd\u62a4\u7684\u5206\u652f\u4e0d\u5141\u8bb8\u8fdb\u884c\u5f3a\u5236\u63a8\u9001, \u89e3\u9664\u6389\u53d7\u4fdd\u62a4\u7684\u5206\u652f\u5373\u53ef, \u7136\u540e\u518d\u6b21\u8fdb\u884c\u5f3a\u5236\u63a8\u9001\u547d\u4ee4\u5373\u53ef.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"C++\" data-enlighter-theme=\"monokai\">\r\ngit push -u origin master -f\r\n<\/pre>\n<p>\u63a8\u5b8c\u4e4b\u540e\u518d\u91cd\u65b0\u4fdd\u62a4\u5373\u53ef.<\/p>\n<p>\u5176\u4e2d-u\u53c2\u6570\u7684\u4f5c\u7528\u662f: \u5982\u679c\u5f53\u524d\u5206\u652f\u4e0e\u591a\u4e2a\u4e3b\u673a\u5b58\u5728\u8ffd\u8e2a\u5173\u7cfb, \u5219\u53ef\u4ee5\u4f7f\u7528-u\u9009\u9879\u6307\u5b9a\u4e00\u4e2a\u9ed8\u8ba4\u4e3b\u673a, \u8fd9\u6837\u540e\u9762\u5c31\u53ef\u4ee5\u4e0d\u52a0\u4efb\u4f55\u53c2\u6570\u4f7f\u7528git push.<\/p>\n<p>PS: \u5173\u4e8eGitLab\u5206\u652f\u4fdd\u62a4\u7684\u8bbe\u7f6e\u53ef\u4ee5\u53c2\u8003<a href=\"https:\/\/blog.51cto.com\/lookingdream\/2062128\">gitLab \u5206\u652f\u53d7\u4fdd\u62a4\u8bbe\u7f6e<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5373\u5c06\u63d0\u4ea4\u6bd5\u4e1a\u8bba\u6587(03.12)\u4e86, \u65f6\u95f4\u6709\u70b9\u7d27, \u8001\u677f\u5408\u4f5c\u7684\u516c\u53f8\u90a3\u8fb9\u53c8\u540c\u65f6\u9700\u8981\u5e72\u6d3b, \u771f\u662f\u5fc3\u529b\u4ea4\u7601, \u53cd\u6b63\u53ea\u80fd &hellip; <a href=\"https:\/\/www.caiqinyi.cn\/index.php\/2020\/03\/01\/gitlab_push_error\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">GitLab\u8bd5\u6c34,\u89e3\u51b3push error<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"_links":{"self":[{"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/posts\/538"}],"collection":[{"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/comments?post=538"}],"version-history":[{"count":7,"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/posts\/538\/revisions"}],"predecessor-version":[{"id":3638,"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/posts\/538\/revisions\/3638"}],"wp:attachment":[{"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/media?parent=538"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/categories?post=538"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/tags?post=538"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}