{"id":208208,"date":"2025-07-08T12:14:29","date_gmt":"2025-07-08T04:14:29","guid":{"rendered":"https:\/\/server.hk\/cnblog\/208208\/"},"modified":"2025-07-08T12:14:29","modified_gmt":"2025-07-08T04:14:29","slug":"go-get-%e4%bc%bc%e4%b9%8e%e5%bf%bd%e7%95%a5%e4%ba%86-gitconfig","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/208208\/","title":{"rendered":"go get \u4f3c\u4e4e\u5ffd\u7565\u4e86 gitconfig"},"content":{"rendered":"<p><b><\/b> <\/p>\n<p>\u5f53\u524d\u4f4d\u7f6e\uff1a <span>&gt;<\/span> <span>&gt;<\/span> <span>&gt;<\/span> <span>&gt;<\/span> <span>go get \u4f3c\u4e4e\u5ffd\u7565\u4e86 gitconfig<\/span><\/p>\n<p><span>\u6765\u6e90\uff1astackoverflow<\/span><br \/>\n<span>2024-04-30 11:42:37<\/span><br \/>\n<span><i><\/i>0\u6d4f\u89c8<\/span><br \/>\n<span style=\"cursor: pointer\"><i><\/i>\u6536\u85cf<\/span> <\/p>\n<p>\u6700\u8fd1\u53d1\u73b0\u4e0d\u5c11\u5c0f\u4f19\u4f34\u90fd\u5bf9<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">Golang<\/span>\u5f88\u611f\u5174\u8da3\uff0c\u6240\u4ee5\u4eca\u5929\u7ee7\u7eed\u7ed9\u5927\u5bb6\u4ecb\u7ecd<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">Golang<\/span>\u76f8\u5173\u7684\u77e5\u8bc6\uff0c\u672c\u6587<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300ago get \u4f3c\u4e4e\u5ffd\u7565\u4e86 gitconfig\u300b<\/span>\u4e3b\u8981\u5185\u5bb9\u6d89\u53ca\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\u77e5\u8bc6\u70b9\uff0c\u5e0c\u671b\u80fd\u5e2e\u5230\u4f60\uff01\u5f53\u7136\u5982\u679c\u9605\u8bfb\u672c\u6587\u65f6\u5b58\u5728\u4e0d\u540c\u60f3\u6cd5\uff0c\u53ef\u4ee5\u5728\u8bc4\u8bba\u4e2d\u8868\u8fbe\uff0c\u4f46\u662f\u8bf7\u52ff\u4f7f\u7528\u8fc7\u6fc0\u7684\u63aa\u8f9e~<\/p>\n<p> \u95ee\u9898\u5185\u5bb9<br \/>\n <\/p>\n<p>\u5bfb\u6c42\u4e00\u4e9b\u5e2e\u52a9\u3002\u6211\u6709\u4e00\u4e2a\u6258\u7ba1\u5728\u8fdc\u7a0b gitlab \u5b9e\u4f8b\u4e0a\u7684\u79c1\u6709\u5b58\u50a8\u5e93\uff0c\u6211\u5e94\u8be5\u80fd\u591f\u8bbf\u95ee\u5b83\u3002\u4f46\u65e0\u8bba\u6211\u5c1d\u8bd5\u4ec0\u4e48\uff0c <code>go get<\/code> \u4f3c\u4e4e\u90fd\u5728\u5c1d\u8bd5\u4f7f\u7528 https \u800c\u4e0d\u662f ssh\u3002\u6211\u53ef\u4ee5 <code>git clone<\/code>\u3001<code>git fetch<\/code>\u3001<code>etc<\/code> \u6ca1\u6709\u4efb\u4f55\u95ee\u9898\u3002\u4f46\u662f\u5f53\u6211\u4f7f\u7528 <code>go get<\/code> \u65f6\uff0c\u5b83\u5c31\u5931\u8d25\u4e86\u3002<\/p>\n<p>\u6211\u505a\u7684\u7b2c\u4e00\u4ef6\u4e8b\u5c31\u662f\u6dfb\u52a0\u8fd9\u4e2a\uff1a <code>git config --global --add url.\"[email&nbsp;protected]:\".insteadof \"https:\/\/git.mydomain.io\/\"<\/code><\/p>\n<p>\u7136\u540e\u6211 cd \u5230\u6211\u7684\u9879\u76ee\u76ee\u5f55\u5e76\u8fd0\u884c go get\uff0c\u4f46\u5c1d\u8bd5\u901a\u8fc7 https \u8fdb\u884c\u8eab\u4efd\u9a8c\u8bc1\u5931\u8d25\uff0c\u5e76\u663e\u793a\u201c\u81f4\u547d\uff1a\u65e0\u6cd5\u8bfb\u53d6\u201chttps:\/\/git.my.domain\u201d\u7684\u7528\u6237\u540d\uff1a\u7ec8\u7aef\u63d0\u793a\u5df2\u7981\u7528\u201d\uff1a <\/p>\n<pre>ps c:\\users\\user\\go\\src\\git.my.domain\\ps\\wk\\collector&gt; go get            \ngo: downloading git.my.domain\/ps\/mqtt v0.0.0-20220903204713-6f195510d46e\ngo: git.my.domain\/ps\/[email&nbsp;protected]: verifying module: git.my.domain\/ps\/[email&nbsp;protected]: reading https:\/\/sum.golang.orglookup\/git.my.domain\/ps\/[email&nbsp;protected]: 404 not found\n        server response:\n        not found: git.my.domain\/ps\/[email&nbsp;protected]: invalid version: git ls-remote -q origin in \/tmp\/gopath\/pkg\/mod\/cache\/v\ncs\/3a728c5d3b6137ea441372540f3e7bc1390c001346a70d5b7df3eda6d5e7316d: exit status 128:\n                fatal: could not read username for 'https:\/\/git.my.domain': terminal prompts disabled\n        confirm the import path was entered correctly.\n        if this is a private repository, see https:\/\/golang.org\/doc\/faq#git_https for additional information.\ngo: git.my.domain\/ps\/[email&nbsp;protected]: verifying module: git.my.domain\/ps\/[email&nbsp;protected]: reading https:\/\/sum.golang.org\/lookup\/git.my.domain\/ps\/[email&nbsp;protected]: 404 not found\n        server response:\n        not found: git.my.domain\/ps\/[email&nbsp;protected]: invalid version: git ls-remote -q origin in \/tmp\/gopath\/pkg\/mod\/cache\/v\ncs\/3a728c5d3b6137ea441372540f3e7bc1390c001346a70d5b7df3eda6d5e7316d: exit status 128:\n                fatal: could not read username for 'https:\/\/git.my.domain': terminal prompts disabled\n        confirm the import path was entered correctly.\n        if this is a private repository, see https:\/\/golang.org\/doc\/faq#git_https for additional information.\ngo: module git.my.domain\/ps\/wk\/collector\/service: git ls-remote -q origin in c:\\users\\user\\go\\pkg\\mod\\cache\\vcs\\7d02e96755cff57eaec3323ab70c24a12ab19\neac805790ed1220d62b15affcf8: exit status 128:\n        remote:\n        remote: ========================================================================\n        remote:\n        remote: the project you were looking for could not be found.\n        remote:\n        remote: ========================================================================\n        remote:\n        fatal: could not read from remote repository.\n\n        please make sure you have the correct access rights\n        and the repository exists.\ngo: module git.my.domain\/ps\/wk\/collector\/service\/service: git ls-remote -q origin in c:\\users\\user\\go\\pkg\\mod\\cache\\vcs\\7d02e96755cff57eaec3323ab70c2\n4a12ab19eac805790ed1220d62b15affcf8: exit status 128:\n        remote:\n        remote: ========================================================================\n        remote:\n        remote: the project you were looking for could not be found.\n        remote:\n        remote: ========================================================================\n        remote:\n        fatal: could not read from remote repository.\n\n        please make sure you have the correct access rights\n        and the repository exists.<\/pre>\n<p>\u6211\u5feb\u8981\u75af\u4e86\u3002\u6211\u5df2\u7ecf\u5c1d\u8bd5\u4e86\u8ba9 <code>go get<\/code> \u4f7f\u7528 ssh \u7684\u5404\u79cd\u7ec4\u5408\uff1a<\/p>\n<pre>git config --global --add url.\"[email&nbsp;protected]\/\".insteadof \"https:\/\/git.mydomain.io\/\"\n\ngit config --global --add url.\"[email&nbsp;protected]\".insteadof \"https:\/\/git.mydomain.io\"\n\ngit config --global --add url.\"ssh:\/\/[email&nbsp;protected]:\".insteadof \"https:\/\/git.mydomain.io\/\"\n...<\/pre>\n<p>\u6709\u4ec0\u4e48\u7279\u522b\u7684\u4e8b\u60c5\u6211\u5fc5\u987b\u5728\u67d0\u4e2a\u5730\u65b9\u505a\u5417\uff1f\u6211\u53ea\u662f\u4e0d\u660e\u767d\u4e3a\u4ec0\u4e48 <code>go get<\/code> \u4f7f\u7528 https\uff0c\u800c git \u547d\u4ee4\u4f3c\u4e4e\u6b63\u786e\u4f7f\u7528 ssh..<\/p>\n<p>======================<\/p>\n<p>\u7f16\u8f91\uff1a\u597d\u5427\uff0c\u66f4\u591a\u7684\u8fc7\u671f\u8ba9\u6211\u610f\u8bc6\u5230\u8fd9\u662f\u6709\u6548\u7684\uff1a<\/p>\n<p><code>[url \"ssh:\/\/[\u7535\u5b50\u90ae\u4ef6\u53d7\u4fdd\u62a4]\"]\u4ee3\u66ff= https:\/\/git.mydomain.io\/<\/code><\/p>\n<p>\u56e0\u4e3a\u6211\u6536\u5230\u4e00\u4e2a\u65b0\u9519\u8bef\uff1a<\/p>\n<pre>ssh: Could not resolve hostname git.mydomain.iops: Name or service not known\n        fatal: Could not read from remote repository.<\/pre>\n<p>\u4f46\u662f\uff0c\u4e00\u65e6\u6211\u6dfb\u52a0\u5c3e\u90e8\u659c\u6760\u6765\u4fee\u590d\u5b83\uff0c\u6211\u5c31\u4f1a\u56de\u5230 https \u9519\u8bef\u3002 https \u65b9\u9762\u662f\u5426\u6709\u53d1\u751f\u5728 ssh \u4e4b\u524d\u7684\u4e8b\u60c5\uff1f<\/p>\n<p> <\/p>\n<h2>\u6b63\u786e\u7b54\u6848<\/h2>\n<p> <\/p>\n<p>\u5c1d\u8bd5\u76f4\u63a5\u4fee\u6539\u60a8\u7684 <code>~\/.gitconfig<\/code> \u6587\u4ef6\uff0c\u786e\u4fdd\u60a8\u7684\u79c1\u6709\u5b58\u50a8\u5e93\u7684\u6761\u76ee\u5982\u4e0b\u6240\u793a<\/p>\n<pre>[url \":\"] insteadOf = https:\/\/gitlab.com<\/pre>\n<p>\u4e5f\u8bb8\u6709\u8bed\u6cd5\u65b9\u9762\u7684\u4e1c\u897f\u3002<\/p>\n<p>\u8fd8\u5c06\u7f51\u5740\uff08\u4e0d\u5e26 <code>https:\/\/<\/code>\uff09\u6dfb\u52a0\u5230\u60a8\u7684 <code>$gonoproxy<\/code> \u4e2d\u3002<\/p>\n<p>\u6587\u4e2d\u5173\u4e8e\u7684\u77e5\u8bc6\u4ecb\u7ecd\uff0c\u5e0c\u671b\u5bf9\u4f60\u7684\u5b66\u4e60\u6709\u6240\u5e2e\u52a9\uff01\u82e5\u662f\u53d7\u76ca\u532a\u6d45\uff0c\u90a3\u5c31\u52a8\u52a8\u9f20\u6807\u6536\u85cf\u8fd9\u7bc7\u300ago get \u4f3c\u4e4e\u5ffd\u7565\u4e86 gitconfig\u300b\u6587\u7ae0\u5427\uff0c\u4e5f\u53ef\u5173\u6ce8\u516c\u4f17\u53f7\u4e86\u89e3\u76f8\u5173\u6280\u672f\u6587\u7ae0\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f53\u524d\u4f4d\u7f6e\uff1a &gt; &gt; &#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-208208","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/208208","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=208208"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/208208\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=208208"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=208208"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=208208"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}