{"id":20114,"date":"2024-11-19T14:19:11","date_gmt":"2024-11-19T06:19:11","guid":{"rendered":"https:\/\/fwq.ai\/blog\/20114\/"},"modified":"2024-11-19T14:19:11","modified_gmt":"2024-11-19T06:19:11","slug":"%e8%bf%9b%e5%85%a5gitlab%e6%8e%a7%e5%88%b6%e5%8f%b0%e7%9a%84%e5%91%bd%e4%bb%a4%e6%98%af%e4%bb%80%e4%b9%88","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/20114\/","title":{"rendered":"\u8fdb\u5165gitlab\u63a7\u5236\u53f0\u7684\u547d\u4ee4\u662f\u4ec0\u4e48"},"content":{"rendered":"<p>\u8fdb\u5165gitlab\u63a7\u5236\u53f0\u7684\u547d\u4ee4<\/p>\n<p>GitLab\u662f\u4e00\u4e2a\u57fa\u4e8eGit\u7684\u4ee3\u7801\u6258\u7ba1\u5e73\u53f0\uff0c\u53ef\u7528\u4e8e\u7ba1\u7406\u548c\u534f\u4f5c\u5f00\u53d1\u3002<\/p>\n<p>\u5728\u4f7f\u7528GitLab\u65f6\uff0c\u6709\u65f6\u6211\u4eec\u9700\u8981\u8fdb\u5165GitLab\u63a7\u5236\u53f0\u8fdb\u884c\u4e00\u4e9b\u7ba1\u7406\u64cd\u4f5c\u3002\u90a3\u4e48\uff0c\u8fdb\u5165gitlab\u63a7\u5236\u53f0\u7684\u547d\u4ee4\u662f\u4ec0\u4e48\u5462\uff1f<\/p>\n<p>\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u5165GitLab\u63a7\u5236\u53f0\uff1a<\/p>\n<pre>sudo gitlab-rails console<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8fd9\u4e2a\u547d\u4ee4\u4e0eRails Console\u547d\u4ee4\u76f8\u540c\uff0c\u53ef\u4ee5\u6253\u5f00\u4e00\u4e2a\u547d\u4ee4\u884c\u754c\u9762\uff0c\u8ba9\u4f60\u53ef\u4ee5\u5728\u63a7\u5236\u53f0\u4e0a\u8f93\u5165\u547d\u4ee4\uff0c\u8fdb\u884c\u5404\u79cd\u7ba1\u7406\u64cd\u4f5c\u3002<\/p>\n<p>\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u5165GitLab\u63a7\u5236\u53f0\uff1a<\/p>\n<pre>gitlab-rails console<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>Linux\u548cWindows\u7684\u547d\u4ee4\u6709\u4e9b\u8bb8\u4e0d\u540c\uff0c\u4e3b\u8981\u662f\u56e0\u4e3aLinux\u7cfb\u7edf\u9700\u8981\u4f7f\u7528sudo\u6765\u83b7\u53d6root\u6743\u9650\uff0c\u800cWindows\u7cfb\u7edf\u5219\u4e0d\u9700\u8981\u3002<\/p>\n<p>\u4f7f\u7528\u4e0a\u8ff0\u547d\u4ee4\u8fdb\u5165GitLab\u63a7\u5236\u53f0\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u8fdb\u884c\u4e00\u4e9b\u5e38\u7528\u7684\u7ba1\u7406\u64cd\u4f5c\uff0c\u4f8b\u5982\uff1a<\/p>\n<ol>\n<li>\u6dfb\u52a0\u7528\u6237<\/li>\n<\/ol>\n<pre>user = User.create!(\n  name: 'username',\n  email: 'user@example.com',\n  password: 'password',\n  password_confirmation: 'password'\n)<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5728\u63a7\u5236\u53f0\u4e0a\u8f93\u5165\u4ee5\u4e0a\u547d\u4ee4\uff0c\u5c31\u53ef\u4ee5\u6dfb\u52a0\u4e00\u4e2a\u65b0\u7684\u7528\u6237\u3002<\/p>\n<ol>\n<li>\u67e5\u770b\u7528\u6237\u5217\u8868<\/li>\n<\/ol>\n<pre>users = User.all<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5728\u63a7\u5236\u53f0\u4e0a\u8f93\u5165\u4ee5\u4e0a\u547d\u4ee4\uff0c\u5c31\u53ef\u4ee5\u67e5\u770b\u6240\u6709\u7528\u6237\u7684\u5217\u8868\u3002<\/p>\n<ol>\n<li>\u67e5\u770b\u9879\u76ee\u5217\u8868<\/li>\n<\/ol>\n<pre>projects = Project.all<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5728\u63a7\u5236\u53f0\u4e0a\u8f93\u5165\u4ee5\u4e0a\u547d\u4ee4\uff0c\u5c31\u53ef\u4ee5\u67e5\u770b\u6240\u6709\u9879\u76ee\u7684\u5217\u8868\u3002<\/p>\n<ol>\n<li>\u6dfb\u52a0SSH\u5bc6\u94a5<\/li>\n<\/ol>\n<pre>key = Key.create!(\n  title: 'title',\n  key: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQ...'\n  type: 'SSHKey',\n  user_id: user.id\n)<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5728\u63a7\u5236\u53f0\u4e0a\u8f93\u5165\u4ee5\u4e0a\u547d\u4ee4\uff0c\u5c31\u53ef\u4ee5\u6dfb\u52a0\u4e00\u4e2aSSH\u5bc6\u94a5\u3002<\/p>\n<p>\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u4f7f\u7528GitLab\u63a7\u5236\u53f0\u8fdb\u884c\u7ba1\u7406\u64cd\u4f5c\u65f6\uff0c\u4e00\u5b9a\u8981\u5c0f\u5fc3\u8c28\u614e\uff0c\u907f\u514d\u8bef\u64cd\u4f5c\u9020\u6210\u4e0d\u5fc5\u8981\u7684\u635f\u5931\u3002\u540c\u65f6\uff0c\u4e5f\u8981\u8bb0\u5f97\u5907\u4efd\u91cd\u8981\u7684\u6570\u636e\uff0c\u4ee5\u9632\u6b62\u6570\u636e\u4e22\u5931\u3002<\/p>\n<p>\u603b\u7ed3<\/p>\n<p>\u8fdb\u5165gitlab\u63a7\u5236\u53f0\u7684\u547d\u4ee4\u5206\u522b\u662f\u5728Linux\u7cfb\u7edf\u4e2d\u4f7f\u7528sudo gitlab-rails console\uff0c\u5728Windows\u7cfb\u7edf\u4e2d\u4f7f\u7528gitlab-rails console\u3002\u5728\u63a7\u5236\u53f0\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u8fdb\u884c\u4e00\u4e9b\u5e38\u7528\u7684\u7ba1\u7406\u64cd\u4f5c\uff0c\u4f8b\u5982\u6dfb\u52a0\u7528\u6237\u3001\u67e5\u770b\u7528\u6237\u5217\u8868\u3001\u67e5\u770b\u9879\u76ee\u5217\u8868\uff0c\u4ee5\u53ca\u6dfb\u52a0SSH\u5bc6\u94a5\u7b49\u3002\u4f7f\u7528\u63a7\u5236\u53f0\u8fdb\u884c\u7ba1\u7406\u64cd\u4f5c\u65f6\uff0c\u4e00\u5b9a\u8981\u5c0f\u5fc3\u8c28\u614e\uff0c\u907f\u514d\u8bef\u64cd\u4f5c\u9020\u6210\u4e0d\u5fc5\u8981\u7684\u635f\u5931\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u8fdb\u5165gitlab\u63a7\u5236\u53f0\u7684\u547d\u4ee4\u662f\u4ec0\u4e48\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fdb\u5165gitlab\u63a7\u5236\u53f0\u7684\u547d\u4ee4 GitLab\u662f\u4e00\u4e2a\u57fa\u4e8eGit\u7684\u4ee3\u7801\u6258\u7ba1\u5e73\u53f0\uff0c\u53ef\u7528\u4e8e\u7ba1\u7406\u548c\u534f\u4f5c\u5f00\u53d1\u3002 \u5728\u4f7f\u7528GitLab\u65f6\uff0c\u6709\u65f6\u6211\u4eec\u9700\u8981\u8fdb\u5165GitLab\u63a7\u5236\u53f0\u8fdb\u884c\u4e00\u4e9b\u7ba1\u7406\u64cd\u4f5c\u3002\u90a3\u4e48\uff0c\u8fdb\u5165gitlab\u63a7\u5236\u53f0\u7684\u547d\u4ee4\u662f\u4ec0\u4e48\u5462\uff1f \u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u5165GitLab\u63a7\u5236\u53f0\uff1a sudo gitlab-rails console \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u4e2a\u547d\u4ee4\u4e0eRails Console\u547d\u4ee4\u76f8\u540c\uff0c\u53ef\u4ee5\u6253\u5f00\u4e00\u4e2a\u547d\u4ee4\u884c\u754c\u9762\uff0c\u8ba9\u4f60\u53ef\u4ee5\u5728\u63a7\u5236\u53f0\u4e0a\u8f93\u5165\u547d\u4ee4\uff0c\u8fdb\u884c\u5404\u79cd\u7ba1\u7406\u64cd\u4f5c\u3002 \u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u5165GitLab\u63a7\u5236\u53f0\uff1a gitlab-rails console \u767b\u5f55\u540e\u590d\u5236 Linux\u548cWindows\u7684\u547d\u4ee4\u6709\u4e9b\u8bb8\u4e0d\u540c\uff0c\u4e3b\u8981\u662f\u56e0\u4e3aLinux\u7cfb\u7edf\u9700\u8981\u4f7f\u7528sudo\u6765\u83b7\u53d6root\u6743\u9650\uff0c\u800cWindows\u7cfb\u7edf\u5219\u4e0d\u9700\u8981\u3002 \u4f7f\u7528\u4e0a\u8ff0\u547d\u4ee4\u8fdb\u5165GitLab\u63a7\u5236\u53f0\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u8fdb\u884c\u4e00\u4e9b\u5e38\u7528\u7684\u7ba1\u7406\u64cd\u4f5c\uff0c\u4f8b\u5982\uff1a \u6dfb\u52a0\u7528\u6237 user = User.create!( name: &#8216;username&#8217;, email: &#8216;user@example.com&#8217;, password: &#8216;password&#8217;, password_confirmation: &#8216;password&#8217; ) \u767b\u5f55\u540e\u590d\u5236 \u5728\u63a7\u5236\u53f0\u4e0a\u8f93\u5165\u4ee5\u4e0a\u547d\u4ee4\uff0c\u5c31\u53ef\u4ee5\u6dfb\u52a0\u4e00\u4e2a\u65b0\u7684\u7528\u6237\u3002 \u67e5\u770b\u7528\u6237\u5217\u8868 users = User.all \u767b\u5f55\u540e\u590d\u5236 \u5728\u63a7\u5236\u53f0\u4e0a\u8f93\u5165\u4ee5\u4e0a\u547d\u4ee4\uff0c\u5c31\u53ef\u4ee5\u67e5\u770b\u6240\u6709\u7528\u6237\u7684\u5217\u8868\u3002 \u67e5\u770b\u9879\u76ee\u5217\u8868 projects = Project.all \u767b\u5f55\u540e\u590d\u5236 \u5728\u63a7\u5236\u53f0\u4e0a\u8f93\u5165\u4ee5\u4e0a\u547d\u4ee4\uff0c\u5c31\u53ef\u4ee5\u67e5\u770b\u6240\u6709\u9879\u76ee\u7684\u5217\u8868\u3002 \u6dfb\u52a0SSH\u5bc6\u94a5 key = Key.create!( title: &#8216;title&#8217;, key: &#8216;ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQ&#8230;&#8217; type: &#8216;SSHKey&#8217;, user_id: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-20114","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/20114","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=20114"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/20114\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=20114"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=20114"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=20114"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}