{"id":269806,"date":"2024-05-16T12:15:42","date_gmt":"2024-05-16T04:15:42","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/269806.html"},"modified":"2024-05-16T12:15:50","modified_gmt":"2024-05-16T04:15:50","slug":"%e5%88%9b%e5%bb%ba-git-%e9%a1%b9%e7%9b%ae%e9%9c%80%e8%a6%81%e4%bb%80%e4%b9%88","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/269806.html","title":{"rendered":"\u521b\u5efa git \u9879\u76ee\u9700\u8981\u4ec0\u4e48"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24183615\/7cf9ea28-e080-4230-8955-aefb4dbb2bda.webp\" alt=\"\u521b\u5efa git \u9879\u76ee\u9700\u8981\u4ec0\u4e48\" \/><\/p>\n<p><p>\u521b\u5efa\u4e00\u4e2aGit\u9879\u76ee\u9700\u8981\uff1a<strong>\u7248\u672c\u63a7\u5236\u8f6f\u4ef6Git\u7684\u5b89\u88c5\u3001\u521d\u59cb\u5316\u4e00\u4e2a\u65b0\u7684\u4ed3\u5e93\u3001\u914d\u7f6e\u7528\u6237\u4fe1\u606f\u3001\u6587\u4ef6\u6dfb\u52a0\u548c\u63d0\u4ea4\uff0c\u5e76\u53ef\u9009\u7684\u8fde\u63a5\u5230\u8fdc\u7a0b\u4ed3\u5e93<\/strong>\u3002\u5176\u4e2d\uff0c<strong>\u7248\u672c\u63a7\u5236\u8f6f\u4ef6Git\u7684\u5b89\u88c5<\/strong>\u662f\u57fa\u7840\uff0c\u56e0\u4e3a\u4e0d\u5b89\u88c5Git\uff0c\u5c31\u65e0\u6cd5\u6267\u884cGit\u547d\u4ee4\u548c\u7ba1\u7406\u9879\u76ee\u7684\u7248\u672c\u3002<\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u786e\u4fdd\u4f60\u7684\u8ba1\u7b97\u673a\u4e0a\u5b89\u88c5\u4e86Git\u3002\u6839\u636e\u4f60\u7684\u64cd\u4f5c\u7cfb\u7edf\uff08\u5982Windows\u3001MacOS\u3001\u6216Linux\uff09\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u5404\u81ea\u7684\u5b89\u88c5\u65b9\u5f0f\u6765\u83b7\u53d6Git\u3002\u4e00\u65e6Git\u88ab\u5b89\u88c5\uff0c\u4f60\u5c31\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u884c\u754c\u9762\u4f7f\u7528\u5b83\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001GIT\u5b89\u88c5\u4e0e\u914d\u7f6e<\/h3>\n<\/p>\n<p><h4>\u5b89\u88c5Git<\/h4>\n<\/p>\n<p><p>\u8bbf\u95eeGit\u7684\u5b98\u65b9\u7f51\u7ad9\uff0c\u4e0b\u8f7d\u7b26\u5408\u4f60\u64cd\u4f5c\u7cfb\u7edf\u7684Git\u7248\u672c\u3002\u5bf9\u4e8eWindows\u7528\u6237\uff0c\u7ecf\u5e38\u662f\u4e00\u4e2a.exe\u5b89\u88c5\u7a0b\u5e8f\u3002Mac\u7528\u6237\u53ef\u80fd\u4f1a\u4e0b\u8f7d\u4e00\u4e2a.dmg\u6587\u4ef6\uff0c\u800cLinux\u7528\u6237\u7ecf\u5e38\u901a\u8fc7\u4ed6\u4eec\u7684\u5305\u7ba1\u7406\u5668\u6765\u5b89\u88c5Git\u3002<\/p>\n<\/p>\n<p><h4>\u914d\u7f6e\u7528\u6237\u4fe1\u606f<\/h4>\n<\/p>\n<p><p>\u5b89\u88c5Git\u540e\uff0c\u9700\u8981\u8bbe\u7f6e\u4f60\u7684\u7528\u6237\u540d\u548c\u7535\u5b50\u90ae\u4ef6\u5730\u5740\u3002\u8fd9\u5bf9\u4e8e\u8bc6\u522b\u63d0\u4ea4\u662f\u5fc5\u8981\u7684\u3002\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u8fdb\u884c\u914d\u7f6e\uff1a<\/p>\n<\/p>\n<p><pre><code>git config --global user.name &quot;Your Name&quot;<\/p>\n<p>git config --global user.em<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>l &quot;youremail@example.com&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4f1a\u5728\u4f60\u7684\u8ba1\u7b97\u673a\u4e0a\u4e3a\u6240\u6709Git\u4ed3\u5e93\u8bbe\u7f6e\u7528\u6237\u4fe1\u606f\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u521d\u59cb\u5316\u4ed3\u5e93<\/h3>\n<\/p>\n<p><h4>\u521b\u5efa\u65b0\u76ee\u5f55<\/h4>\n<\/p>\n<p><p>\u6253\u5f00\u547d\u4ee4\u884c\uff0c\u9009\u62e9\u4e00\u4e2a\u5408\u9002\u7684\u5730\u65b9\u521b\u5efa\u65b0\u76ee\u5f55\u4f5c\u4e3a\u4f60\u7684\u9879\u76ee\u6587\u4ef6\u5939\uff1a<\/p>\n<\/p>\n<p><pre><code>mkdir project-name<\/p>\n<p>cd project-name<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u521d\u59cb\u5316Git\u4ed3\u5e93<\/h4>\n<\/p>\n<p><p>\u5728\u9879\u76ee\u6587\u4ef6\u5939\u5185\uff0c\u6267\u884c\u521d\u59cb\u5316\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code>git init<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a\u547d\u4ee4\u4f1a\u521b\u5efa\u4e00\u4e2a\u65b0\u7684<code>.git<\/code>\u5b50\u76ee\u5f55\uff0c\u8fd9\u4e2a\u6587\u4ef6\u5939\u5305\u542b\u4e86\u5c06\u6765\u7528\u4e8e\u7248\u672c\u8ddf\u8e2a\u7684\u6240\u6709\u5fc5\u8981\u5143\u6570\u636e\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u6587\u4ef6\u7684\u6dfb\u52a0\u4e0e\u63d0\u4ea4<\/h3>\n<\/p>\n<p><h4>\u6dfb\u52a0\u6587\u4ef6<\/h4>\n<\/p>\n<p><p>\u901a\u8fc7<code>git add<\/code>\u6765\u6dfb\u52a0\u4e00\u4e2a\u6216\u591a\u4e2a\u6587\u4ef6\u5230\u6682\u5b58\u533a\uff1a<\/p>\n<\/p>\n<p><pre><code>git add &lt;filename&gt;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216\u8005\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528<code>.<\/code>\u6765\u6dfb\u52a0\u6240\u6709\u53d8\u66f4\u8fc7\u7684\u6587\u4ef6\uff1a<\/p>\n<\/p>\n<p><pre><code>git add .<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>\u63d0\u4ea4\u53d8\u66f4<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528<code>git commit<\/code>\u547d\u4ee4\u6765\u8bb0\u5f55\u4f60\u7684\u53d8\u52a8\uff1a<\/p>\n<\/p>\n<p><pre><code>git commit -m &quot;Initial commit&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6bcf\u4e2a\u63d0\u4ea4\u90fd\u9700\u8981\u6709\u76f8\u5e94\u7684\u4fe1\u606f\u63cf\u8ff0\u8fd9\u6b21\u53d8\u52a8\u7684\u5185\u5bb9\uff0c\u5229\u4e8e\u672a\u6765\u56de\u987e\u548c\u7406\u89e3\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u8fde\u63a5\u5230\u8fdc\u7a0b\u4ed3\u5e93<\/h3>\n<\/p>\n<p><h4>\u521b\u5efa\u8fdc\u7a0b\u4ed3\u5e93<\/h4>\n<\/p>\n<p><p>\u4f60\u53ef\u4ee5\u5728\u50cfGitHub\u3001GitLab\u6216Bitbucket\u8fd9\u6837\u7684\u4ee3\u7801\u6258\u7ba1\u670d\u52a1\u4e0a\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u4ed3\u5e93\u3002<\/p>\n<\/p>\n<p><h4>\u8fde\u63a5\u672c\u5730\u548c\u8fdc\u7a0b\u4ed3\u5e93<\/h4>\n<\/p>\n<p><p>\u786e\u5b9a\u8fdc\u7a0b\u4ed3\u5e93\u7684URL\uff0c\u7136\u540e\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u6765\u5173\u8054\u672c\u5730\u548c\u8fdc\u7a0b\u4ed3\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code>git remote add origin remote-repository-URL<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5c06<code>remote-repository-URL<\/code>\u66ff\u6362\u4e3a\u5b9e\u9645\u7684\u8fdc\u7a0b\u4ed3\u5e93URL\u3002<\/p>\n<\/p>\n<p><h4>\u63a8\u9001\u5230\u8fdc\u7a0b\u4ed3\u5e93<\/h4>\n<\/p>\n<p><p>\u6700\u540e\uff0c\u7528<code>git push<\/code>\u547d\u4ee4\u5c06\u672c\u5730\u4ed3\u5e93\u7684\u5185\u5bb9\u63a8\u9001\u5230\u8fdc\u7a0b\u4ed3\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code>git push -u origin master<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u6837\uff0c\u4f60\u5c31\u5b8c\u6210\u4e86\u521b\u5efaGit\u9879\u76ee\u7684\u6240\u6709\u57fa\u672c\u6b65\u9aa4\u3002\u540e\u7eed\uff0c\u4f60\u53ef\u4ee5\u5f00\u59cb\u4f60\u7684\u5f00\u53d1\u5de5\u4f5c\uff0c\u4f7f\u7528git\u547d\u4ee4\u6765\u8fdb\u884c\u7248\u672c\u63a7\u5236\u548c\u534f\u4f5c\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>1. \u521b\u5efa git \u9879\u76ee\u9700\u8981\u51c6\u5907\u54ea\u4e9b\u5de5\u5177\u548c\u73af\u5883\uff1f<\/strong><br \/>\n\u5728\u521b\u5efa git \u9879\u76ee\u4e4b\u524d\uff0c\u60a8\u9700\u8981\u786e\u4fdd\u60a8\u5df2\u7ecf\u5b89\u88c5\u4e86Git\u5de5\u5177\uff0c\u53ef\u4ee5\u4eceGit\u7684\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u5e76\u5b89\u88c5\u3002\u53e6\u5916\uff0c\u60a8\u8fd8\u9700\u8981\u4e00\u4e2a\u672c\u5730\u7684\u5f00\u53d1\u73af\u5883\uff0c\u53ef\u4ee5\u662f\u4efb\u4f55\u6587\u672c\u7f16\u8f91\u5668\u6216\u8005\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u3002<\/p>\n<p><strong>2. \u5982\u4f55\u5728\u672c\u5730\u521b\u5efa\u4e00\u4e2a\u65b0\u7684 git \u9879\u76ee\uff1f<\/strong><br \/>\n\u8981\u5728\u672c\u5730\u521b\u5efa\u65b0\u7684Git\u9879\u76ee\uff0c\u9996\u5148\u60a8\u9700\u8981\u6253\u5f00\u547d\u4ee4\u884c\u7ec8\u7aef\u6216\u8005Git Bash\uff08Windows\u7528\u6237\uff09\u5e76\u8fdb\u5165\u5230\u60a8\u60f3\u8981\u521b\u5efa\u5b58\u50a8\u5e93\u7684\u6587\u4ef6\u5939\u3002\u7136\u540e\uff0c\u4f7f\u7528<code>git init<\/code>\u547d\u4ee4\u521d\u59cb\u5316\u4e00\u4e2a\u65b0\u7684Git\u5b58\u50a8\u5e93\u3002\u8fd9\u5c06\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u65b0\u7684.git\u6587\u4ef6\u5939\uff0c\u7528\u4e8e\u5b58\u50a8\u9879\u76ee\u7684\u7248\u672c\u63a7\u5236\u4fe1\u606f\u3002<\/p>\n<p><strong>3. \u5728\u521b\u5efa git \u9879\u76ee\u65f6\u6709\u54ea\u4e9b\u91cd\u8981\u7684\u914d\u7f6e\uff1f<\/strong><br \/>\n\u5728\u521b\u5efaGit\u9879\u76ee\u4e4b\u524d\uff0c\u6709\u4e00\u4e9b\u91cd\u8981\u7684\u914d\u7f6e\u9700\u8981\u6ce8\u610f\u3002\u9996\u5148\uff0c\u60a8\u9700\u8981\u8bbe\u7f6e\u60a8\u7684\u5168\u5c40\u7528\u6237\u540d\u548c\u7535\u5b50\u90ae\u4ef6\u5730\u5740\uff0c\u8fd9\u6837\u5728\u63d0\u4ea4\u4ee3\u7801\u65f6\u53ef\u4ee5\u5c06\u5176\u8bc6\u522b\u4e3a\u60a8\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528<code>git config<\/code>\u547d\u4ee4\u6765\u5b8c\u6210\u8fd9\u4e2a\u8bbe\u7f6e\u3002\u6b64\u5916\uff0c\u60a8\u8fd8\u53ef\u4ee5\u914d\u7f6eGit\u7684\u9ed8\u8ba4\u7f16\u8f91\u5668\u3001\u5dee\u5f02\u5de5\u5177\u3001\u5408\u5e76\u5de5\u5177\u7b49\u3002\u8fd9\u4e9b\u914d\u7f6e\u53ef\u4ee5\u5728Git\u7684\u914d\u7f6e\u6587\u4ef6\uff08.gitconfig\uff09\u4e2d\u8fdb\u884c\u4fee\u6539\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u521b\u5efa\u4e00\u4e2aGit\u9879\u76ee\u9700\u8981\uff1a\u7248\u672c\u63a7\u5236\u8f6f\u4ef6Git\u7684\u5b89\u88c5\u3001\u521d\u59cb\u5316\u4e00\u4e2a\u65b0\u7684\u4ed3\u5e93\u3001\u914d\u7f6e\u7528\u6237\u4fe1\u606f\u3001\u6587\u4ef6\u6dfb\u52a0\u548c\u63d0\u4ea4\uff0c\u5e76\u53ef\u9009\u7684\u8fde [&hellip;]","protected":false},"author":3,"featured_media":269822,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/269806"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=269806"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/269806\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/269822"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=269806"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=269806"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=269806"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}