{"id":20026,"date":"2024-11-19T17:32:47","date_gmt":"2024-11-19T09:32:47","guid":{"rendered":"https:\/\/fwq.ai\/blog\/20026\/"},"modified":"2024-11-19T17:32:47","modified_gmt":"2024-11-19T09:32:47","slug":"git%e9%95%9c%e5%83%8f%e4%bf%ae%e6%94%b9","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/20026\/","title":{"rendered":"git\u955c\u50cf\u4fee\u6539"},"content":{"rendered":"<p>\u968f\u7740git\u7684\u6d41\u884c\uff0c\u4f7f\u7528git\u7684\u4eba\u8d8a\u6765\u8d8a\u591a\u3002\u7531\u4e8egit\u662f\u5206\u5e03\u5f0f\u7684\u7248\u672c\u63a7\u5236\u7cfb\u7edf\uff0c\u5b83\u4f7f\u5f97\u4ee3\u7801\u7684\u5171\u4eab\u548c\u534f\u4f5c\u975e\u5e38\u5bb9\u6613\u3002\u8bb8\u591a\u4eba\u4f7f\u7528\u7684git\u4ed3\u5e93\u53ef\u80fd\u6258\u7ba1\u5728github\u3001gitlab\u3001bitbucket\u7b49\u5e73\u53f0\u4e0a\uff0c\u4f46\u662f\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u4f7f\u7528\u81ea\u5df1\u7684git\u4ed3\u5e93\u3002\u56e0\u6b64\uff0c\u4f7f\u7528git\u955c\u50cf\u662f\u4e00\u79cd\u5f88\u65b9\u4fbf\u7684\u9009\u62e9\u3002\u672c \u6587\u5c06\u4ecb\u7ecdgit\u955c\u50cf\u662f\u4ec0\u4e48\u4ee5\u53ca\u5982\u4f55\u4fee\u6539git\u955c\u50cf\u3002<\/p>\n<p>Git\u955c\u50cf\u662f\u4ec0\u4e48\uff1f<\/p>\n<p>Git\u955c\u50cf\u662f\u6307\u5c06Git\u4ed3\u5e93\u5b8c\u6574\u5730\u590d\u5236\u5230\u53e6\u4e00\u4e2a\u5730\u65b9\uff0c\u4ee5\u4fbf\u5728\u9700\u8981\u7684\u65f6\u5019\u53ef\u4ee5\u66f4\u5feb\u5730\u83b7\u53d6Git\u4ed3\u5e93\u7684\u5185\u5bb9\u3002\u4f8b\u5982\uff0c\u5982\u679c\u60a8\u5728\u4e2d\u56fd\u4f7f\u7528Git\uff0c\u4f46\u662fGit\u4ed3\u5e93\u6258\u7ba1\u5728\u7f8e\u56fd\uff0c\u90a3\u4e48\u60a8\u5c06\u4f1a\u9762\u4e34\u4e00\u4e9b\u7f51\u7edc\u4e0a\u7684\u5ef6\u8fdf\u95ee\u9898\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2aGit\u955c\u50cf\uff0c\u8ba9\u60a8\u66f4\u5feb\u5730\u83b7\u53d6Git\u4ed3\u5e93\u7684\u5185\u5bb9\u3002<\/p>\n<p>\u5982\u4f55\u4fee\u6539Git\u955c\u50cf\uff1f<\/p>\n<p>Git\u4f1a\u81ea\u52a8\u4ece\u5b58\u50a8\u5e93\u4e0b\u8f7d\u6570\u636e\uff0c\u4f46\u662f\u5728\u4e00\u4e9b\u60c5\u51b5\u4e0b\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u4f7f\u7528\u4e0d\u540c\u7684Git\u955c\u50cf\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u793a\u4f8b:<\/p>\n<ul>\n<li>\u60a8\u5fc5\u987b\u4f7f\u7528\u7279\u5b9a\u7684Git\u955c\u50cf\u6e90\uff0c\u56e0\u4e3a\u60a8\u7684\u7f51\u7edc\u8fde\u63a5\u5230Git\u4ed3\u5e93\u7684\u901f\u5ea6\u5f88\u6162\u3002<\/li>\n<li>\u60a8\u9700\u8981\u5728\u6ca1\u6709\u7f51\u7edc\u8fde\u63a5\u7684\u60c5\u51b5\u4e0b\u4f7f\u7528Git\u4ed3\u5e93\uff0c\u56e0\u6b64\u60a8\u9700\u8981\u5c06\u5176\u4fdd\u5b58\u5728\u672c\u5730\u8ba1\u7b97\u673a\u4e0a\u3002<\/li>\n<li>\u60a8\u9700\u8981\u5728\u53d7\u9650\u7684\u7f51\u7edc\u73af\u5883\u4e2d\u4f7f\u7528Git\uff0c\u5982\u516c\u53f8\u9632\u706b\u5899\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0b\u662f\u4fee\u6539Git\u955c\u50cf\u7684\u6b65\u9aa4:<\/p>\n<p>\u7b2c1\u6b65: \u68c0\u67e5\u5f53\u524d\u4f7f\u7528\u7684Git\u955c\u50cf<\/p>\n<p>\u8981\u67e5\u770b\u5f53\u524d\u4f7f\u7528\u7684Git\u955c\u50cf\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4:<\/p>\n<pre>git config --get remote.origin.url<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8be5\u547d\u4ee4\u5c06\u8fd4\u56de\u4e0e\u5916\u90e8Git\u5b58\u50a8\u5e93\u5173\u8054\u7684URL\u3002<\/p>\n<p>\u7b2c2\u6b65: \u8bbe\u7f6e\u4e00\u4e2a\u65b0\u7684Git\u955c\u50cf<\/p>\n<p>\u8981\u8bbe\u7f6e\u4e00\u4e2a\u65b0\u7684Git\u955c\u50cf\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4:<\/p>\n<pre>git remote set-url origin {\u60a8\u7684Git\u955c\u50cfURL}<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4f8b\u5982\uff0c\u5982\u679c\u8981\u5c06\u4e00\u4e2a\u540d\u4e3a\u201cmy_git_mirror\u201d\u7684Git\u955c\u50cf\u8bbe\u7f6e\u4e3a\u8fdc\u7a0b\u5730\u5740\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4:<\/p>\n<pre>git remote set-url origin https:\/\/my_git_mirror<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8bf7\u6ce8\u610f\uff0c\u6b64\u547d\u4ee4\u5c06\u66ff\u6362\u5148\u524d\u5173\u8054\u7684Git\u5b58\u50a8\u5e93URL\u3002<\/p>\n<p>\u7b2c3\u6b65: \u9a8c\u8bc1Git\u955c\u50cf\u662f\u5426\u751f\u6548<\/p>\n<p>\u8981\u9a8c\u8bc1Git\u955c\u50cf\u662f\u5426\u751f\u6548\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4:<\/p>\n<pre>git remote show origin<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8be5\u547d\u4ee4\u5c06\u8fd4\u56de\u73b0\u5df2\u5173\u8054\u5230origin\u7684Git\u955c\u50cf\u53ca\u5176\u8be6\u7ec6\u4fe1\u606f\u3002\u786e\u4fddGit\u955c\u50cf\u662f\u60a8\u5728\u7b2c2\u6b65\u4e2d\u8bbe\u7f6e\u7684\u90a3\u4e2a\u3002<\/p>\n<p>\u7ed3\u8bba<\/p>\n<p>Git\u955c\u50cf\u662f\u4e00\u4e2a\u5f88\u65b9\u4fbf\u7684\u9009\u62e9\uff0c\u5b83\u53ef\u4ee5\u5e2e\u52a9\u60a8\u66f4\u5feb\u5730\u83b7\u53d6Git\u4ed3\u5e93\u7684\u5185\u5bb9\u3002\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u4f7f\u7528\u7279\u5b9a\u7684Git\u955c\u50cf\u6e90\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u60a8\u53ef\u4ee5\u6309\u7167\u4e0a\u8ff0\u6b65\u9aa4\u8f7b\u677e\u5730\u8bbe\u7f6e\u81ea\u5df1\u7684Git\u955c\u50cf\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fgit\u955c\u50cf\u4fee\u6539\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>\u968f\u7740git\u7684\u6d41\u884c\uff0c\u4f7f\u7528git\u7684\u4eba\u8d8a\u6765\u8d8a\u591a\u3002\u7531\u4e8egit\u662f\u5206\u5e03\u5f0f\u7684\u7248\u672c\u63a7\u5236\u7cfb\u7edf\uff0c\u5b83\u4f7f\u5f97\u4ee3\u7801\u7684\u5171\u4eab\u548c\u534f\u4f5c\u975e\u5e38\u5bb9\u6613\u3002\u8bb8\u591a\u4eba\u4f7f\u7528\u7684git\u4ed3\u5e93\u53ef\u80fd\u6258\u7ba1\u5728github\u3001gitlab\u3001bitbucket\u7b49\u5e73\u53f0\u4e0a\uff0c\u4f46\u662f\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u4f7f\u7528\u81ea\u5df1\u7684git\u4ed3\u5e93\u3002\u56e0\u6b64\uff0c\u4f7f\u7528git\u955c\u50cf\u662f\u4e00\u79cd\u5f88\u65b9\u4fbf\u7684\u9009\u62e9\u3002\u672c \u6587\u5c06\u4ecb\u7ecdgit\u955c\u50cf\u662f\u4ec0\u4e48\u4ee5\u53ca\u5982\u4f55\u4fee\u6539git\u955c\u50cf\u3002 Git\u955c\u50cf\u662f\u4ec0\u4e48\uff1f Git\u955c\u50cf\u662f\u6307\u5c06Git\u4ed3\u5e93\u5b8c\u6574\u5730\u590d\u5236\u5230\u53e6\u4e00\u4e2a\u5730\u65b9\uff0c\u4ee5\u4fbf\u5728\u9700\u8981\u7684\u65f6\u5019\u53ef\u4ee5\u66f4\u5feb\u5730\u83b7\u53d6Git\u4ed3\u5e93\u7684\u5185\u5bb9\u3002\u4f8b\u5982\uff0c\u5982\u679c\u60a8\u5728\u4e2d\u56fd\u4f7f\u7528Git\uff0c\u4f46\u662fGit\u4ed3\u5e93\u6258\u7ba1\u5728\u7f8e\u56fd\uff0c\u90a3\u4e48\u60a8\u5c06\u4f1a\u9762\u4e34\u4e00\u4e9b\u7f51\u7edc\u4e0a\u7684\u5ef6\u8fdf\u95ee\u9898\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2aGit\u955c\u50cf\uff0c\u8ba9\u60a8\u66f4\u5feb\u5730\u83b7\u53d6Git\u4ed3\u5e93\u7684\u5185\u5bb9\u3002 \u5982\u4f55\u4fee\u6539Git\u955c\u50cf\uff1f Git\u4f1a\u81ea\u52a8\u4ece\u5b58\u50a8\u5e93\u4e0b\u8f7d\u6570\u636e\uff0c\u4f46\u662f\u5728\u4e00\u4e9b\u60c5\u51b5\u4e0b\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u4f7f\u7528\u4e0d\u540c\u7684Git\u955c\u50cf\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u793a\u4f8b: \u60a8\u5fc5\u987b\u4f7f\u7528\u7279\u5b9a\u7684Git\u955c\u50cf\u6e90\uff0c\u56e0\u4e3a\u60a8\u7684\u7f51\u7edc\u8fde\u63a5\u5230Git\u4ed3\u5e93\u7684\u901f\u5ea6\u5f88\u6162\u3002 \u60a8\u9700\u8981\u5728\u6ca1\u6709\u7f51\u7edc\u8fde\u63a5\u7684\u60c5\u51b5\u4e0b\u4f7f\u7528Git\u4ed3\u5e93\uff0c\u56e0\u6b64\u60a8\u9700\u8981\u5c06\u5176\u4fdd\u5b58\u5728\u672c\u5730\u8ba1\u7b97\u673a\u4e0a\u3002 \u60a8\u9700\u8981\u5728\u53d7\u9650\u7684\u7f51\u7edc\u73af\u5883\u4e2d\u4f7f\u7528Git\uff0c\u5982\u516c\u53f8\u9632\u706b\u5899\u3002 \u4ee5\u4e0b\u662f\u4fee\u6539Git\u955c\u50cf\u7684\u6b65\u9aa4: \u7b2c1\u6b65: \u68c0\u67e5\u5f53\u524d\u4f7f\u7528\u7684Git\u955c\u50cf \u8981\u67e5\u770b\u5f53\u524d\u4f7f\u7528\u7684Git\u955c\u50cf\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4: git config &#8211;get remote.origin.url \u767b\u5f55\u540e\u590d\u5236 \u8be5\u547d\u4ee4\u5c06\u8fd4\u56de\u4e0e\u5916\u90e8Git\u5b58\u50a8\u5e93\u5173\u8054\u7684URL\u3002 \u7b2c2\u6b65: \u8bbe\u7f6e\u4e00\u4e2a\u65b0\u7684Git\u955c\u50cf \u8981\u8bbe\u7f6e\u4e00\u4e2a\u65b0\u7684Git\u955c\u50cf\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4: git remote set-url origin {\u60a8\u7684Git\u955c\u50cfURL} \u767b\u5f55\u540e\u590d\u5236 \u4f8b\u5982\uff0c\u5982\u679c\u8981\u5c06\u4e00\u4e2a\u540d\u4e3a\u201cmy_git_mirror\u201d\u7684Git\u955c\u50cf\u8bbe\u7f6e\u4e3a\u8fdc\u7a0b\u5730\u5740\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4: git remote set-url origin https:\/\/my_git_mirror \u767b\u5f55\u540e\u590d\u5236 \u8bf7\u6ce8\u610f\uff0c\u6b64\u547d\u4ee4\u5c06\u66ff\u6362\u5148\u524d\u5173\u8054\u7684Git\u5b58\u50a8\u5e93URL\u3002 \u7b2c3\u6b65: \u9a8c\u8bc1Git\u955c\u50cf\u662f\u5426\u751f\u6548 \u8981\u9a8c\u8bc1Git\u955c\u50cf\u662f\u5426\u751f\u6548\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4: git remote show origin \u767b\u5f55\u540e\u590d\u5236 \u8be5\u547d\u4ee4\u5c06\u8fd4\u56de\u73b0\u5df2\u5173\u8054\u5230origin\u7684Git\u955c\u50cf\u53ca\u5176\u8be6\u7ec6\u4fe1\u606f\u3002\u786e\u4fddGit\u955c\u50cf\u662f\u60a8\u5728\u7b2c2\u6b65\u4e2d\u8bbe\u7f6e\u7684\u90a3\u4e2a\u3002 \u7ed3\u8bba Git\u955c\u50cf\u662f\u4e00\u4e2a\u5f88\u65b9\u4fbf\u7684\u9009\u62e9\uff0c\u5b83\u53ef\u4ee5\u5e2e\u52a9\u60a8\u66f4\u5feb\u5730\u83b7\u53d6Git\u4ed3\u5e93\u7684\u5185\u5bb9\u3002\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u4f7f\u7528\u7279\u5b9a\u7684Git\u955c\u50cf\u6e90\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u60a8\u53ef\u4ee5\u6309\u7167\u4e0a\u8ff0\u6b65\u9aa4\u8f7b\u677e\u5730\u8bbe\u7f6e\u81ea\u5df1\u7684Git\u955c\u50cf\u3002 \u4ee5\u4e0a\u5c31\u662fgit\u955c\u50cf\u4fee\u6539\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/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-20026","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/20026","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=20026"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/20026\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=20026"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=20026"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=20026"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}