{"id":344755,"date":"2024-05-23T12:21:01","date_gmt":"2024-05-23T04:21:01","guid":{"rendered":""},"modified":"2024-05-23T12:21:11","modified_gmt":"2024-05-23T04:21:11","slug":"%e6%80%8e%e4%b9%88%e8%ae%a9%e9%a1%b9%e7%9b%ae%e8%a2%abgit%e7%ae%a1%e7%90%86","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/344755.html","title":{"rendered":"\u600e\u4e48\u8ba9\u9879\u76ee\u88abgit\u7ba1\u7406"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2024\/05\/f22194ed-595c-4eee-bc67-b800abc8c198.webp?x-oss-process=image\/auto-orient,1\/format,webp\" alt=\"\u600e\u4e48\u8ba9\u9879\u76ee\u88abgit\u7ba1\u7406\" \/><\/p>\n<p><p><strong>\u8981\u8ba9\u9879\u76ee\u88abGit\u7ba1\u7406\uff0c\u4f60\u9700\u8981\uff1a\u521d\u59cb\u5316Git\u4ed3\u5e93\u3001\u6dfb\u52a0\u6587\u4ef6\u5230\u4ed3\u5e93\u3001\u63d0\u4ea4\u66f4\u6539\u3001\u8bbe\u7f6e\u8fdc\u7a0b\u4ed3\u5e93\u3002<\/strong> \u5176\u4e2d\u6700\u91cd\u8981\u7684\u4e00\u70b9\u662f\u521d\u59cb\u5316Git\u4ed3\u5e93\uff0c\u8fd9\u4e00\u6b65\u9aa4\u4f1a\u521b\u5efa\u4e00\u4e2a\u9690\u85cf\u7684.git\u76ee\u5f55\uff0cGit\u5c06\u4f7f\u7528\u8fd9\u4e2a\u76ee\u5f55\u6765\u8ddf\u8e2a\u9879\u76ee\u4e2d\u7684\u6240\u6709\u66f4\u6539\u3002\u521d\u59cb\u5316\u4ed3\u5e93\u540e\uff0c\u4f60\u53ef\u4ee5\u5f00\u59cb\u6dfb\u52a0\u6587\u4ef6\u5e76\u8fdb\u884c\u63d0\u4ea4\uff0c\u8fd9\u6837Git\u5c31\u80fd\u8bb0\u5f55\u8fd9\u4e9b\u66f4\u6539\u7684\u5386\u53f2\u3002\u6700\u540e\uff0c\u5982\u679c\u4f60\u9700\u8981\u4e0e\u5176\u4ed6\u4eba\u5171\u4eab\u9879\u76ee\uff0c\u4f60\u8fd8\u9700\u8981\u5c06\u672c\u5730\u4ed3\u5e93\u8fde\u63a5\u5230\u4e00\u4e2a\u8fdc\u7a0b\u4ed3\u5e93\u3002<\/p>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u8ba8\u8bba\u5982\u4f55\u5b8c\u6210\u8fd9\u4e9b\u6b65\u9aa4\uff0c\u4ece\u5b89\u88c5Git\u5230\u4f7f\u7528\u5e38\u89c1\u7684Git\u547d\u4ee4\u6765\u7ba1\u7406\u4f60\u7684\u9879\u76ee\u3002<\/p>\n<\/p>\n<h2><strong>\u4e00\u3001\u5b89\u88c5Git<\/strong><\/h2>\n<p><p>\u5728\u5f00\u59cb\u4f7f\u7528Git\u7ba1\u7406\u9879\u76ee\u4e4b\u524d\uff0c\u4f60\u9700\u8981\u9996\u5148\u5b89\u88c5Git\u3002Git\u662f\u4e00\u4e2a\u514d\u8d39\u7684\u5f00\u6e90\u5206\u5e03\u5f0f\u7248\u672c\u63a7\u5236\u7cfb\u7edf\uff0c\u652f\u6301\u5404\u79cd\u64cd\u4f5c\u7cfb\u7edf\u3002<\/p>\n<\/p>\n<p><h2>1.1\u3001\u5728Windows\u4e0a\u5b89\u88c5Git<\/h2>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u8bbf\u95eeGit\u7684\u5b98\u65b9\u7f51\u7ad9 <a href=\"https:\/\/git-scm.com\/\">git-scm.com<\/a>\uff0c\u4e0b\u8f7d\u9002\u7528\u4e8eWindows\u7684\u5b89\u88c5\u7a0b\u5e8f\u3002\u53cc\u51fb\u4e0b\u8f7d\u7684\u5b89\u88c5\u7a0b\u5e8f\u5e76\u6309\u7167\u5411\u5bfc\u5b8c\u6210\u5b89\u88c5\u3002\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u53ef\u4ee5\u9009\u62e9\u4f7f\u7528\u9ed8\u8ba4\u8bbe\u7f6e\uff0c\u6216\u8005\u6839\u636e\u9700\u8981\u81ea\u5b9a\u4e49\u914d\u7f6e\u3002<\/p>\n<\/p>\n<p><h2>1.2\u3001\u5728macOS\u4e0a\u5b89\u88c5Git<\/h2>\n<\/p>\n<p><p>\u5728macOS\u4e0a\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7Homebrew\u6765\u5b89\u88c5Git\u3002\u9996\u5148\uff0c\u786e\u4fdd\u4f60\u5df2\u7ecf\u5b89\u88c5\u4e86Homebrew\uff0c\u7136\u540e\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">brew install git<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u81ea\u52a8\u4e0b\u8f7d\u5e76\u5b89\u88c5Git\u3002<\/p>\n<\/p>\n<p><h2>1.3\u3001\u5728Linux\u4e0a\u5b89\u88c5Git<\/h2>\n<\/p>\n<p><p>\u5728\u5927\u591a\u6570Linux\u53d1\u884c\u7248\u4e0a\uff0cGit\u5df2\u7ecf\u5305\u542b\u5728\u9ed8\u8ba4\u7684\u8f6f\u4ef6\u5305\u7ba1\u7406\u5668\u4e2d\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5Git\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">sudo apt-get install git  # Debian\/Ubuntu<\/p>\n<p>sudo yum install git      # CentOS\/RHEL<\/p>\n<p><\/code><\/pre>\n<\/p>\n<h2><strong>\u4e8c\u3001\u521d\u59cb\u5316Git\u4ed3\u5e93<\/strong><\/h2>\n<p><p>\u521d\u59cb\u5316Git\u4ed3\u5e93\u662f\u5c06\u9879\u76ee\u7eb3\u5165\u7248\u672c\u63a7\u5236\u7684\u7b2c\u4e00\u6b65\u3002\u8fd9\u4e00\u6b65\u9aa4\u5c06\u521b\u5efa\u4e00\u4e2a\u9690\u85cf\u7684.git\u76ee\u5f55\uff0cGit\u5c06\u4f7f\u7528\u8fd9\u4e2a\u76ee\u5f55\u6765\u8ddf\u8e2a\u9879\u76ee\u4e2d\u7684\u6240\u6709\u66f4\u6539\u3002<\/p>\n<\/p>\n<p><h2>2.1\u3001\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Git\u4ed3\u5e93<\/h2>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u5df2\u7ecf\u6709\u4e00\u4e2a\u73b0\u6709\u7684\u9879\u76ee\uff0c\u4f60\u53ef\u4ee5\u5728\u9879\u76ee\u7684\u6839\u76ee\u5f55\u4e0b\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u521d\u59cb\u5316Git\u4ed3\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">git init<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Git\u4ed3\u5e93\uff0c\u5e76\u4e14\u5728\u9879\u76ee\u7684\u6839\u76ee\u5f55\u4e0b\u751f\u6210\u4e00\u4e2a\u9690\u85cf\u7684.git\u76ee\u5f55\u3002<\/p>\n<\/p>\n<p><h2>2.2\u3001\u514b\u9686\u4e00\u4e2a\u73b0\u6709\u7684Git\u4ed3\u5e93<\/h2>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u60f3\u8981\u4ece\u4e00\u4e2a\u5df2\u7ecf\u5b58\u5728\u7684\u8fdc\u7a0b\u4ed3\u5e93\u5f00\u59cb\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u514b\u9686\u8be5\u4ed3\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">git clone https:\/\/github.com\/user\/repository.git<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u4e0b\u8f7d\u8fdc\u7a0b\u4ed3\u5e93\u7684\u6240\u6709\u6587\u4ef6\u5230\u672c\u5730\uff0c\u5e76\u81ea\u52a8\u521d\u59cb\u5316\u4e00\u4e2aGit\u4ed3\u5e93\u3002<\/p>\n<\/p>\n<h2><strong>\u4e09\u3001\u6dfb\u52a0\u6587\u4ef6\u5230Git\u4ed3\u5e93<\/strong><\/h2>\n<p><p>\u521d\u59cb\u5316Git\u4ed3\u5e93\u540e\uff0c\u4f60\u9700\u8981\u5c06\u6587\u4ef6\u6dfb\u52a0\u5230\u4ed3\u5e93\u4e2d\uff0c\u4ee5\u4fbfGit\u80fd\u591f\u5f00\u59cb\u8ddf\u8e2a\u8fd9\u4e9b\u6587\u4ef6\u7684\u66f4\u6539\u3002<\/p>\n<\/p>\n<p><h2>3.1\u3001\u6dfb\u52a0\u6587\u4ef6\u5230\u6682\u5b58\u533a<\/h2>\n<\/p>\n<p><p>\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5c06\u6587\u4ef6\u6dfb\u52a0\u5230Git\u7684\u6682\u5b58\u533a\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">git add filename<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u60f3\u4e00\u6b21\u6027\u6dfb\u52a0\u6240\u6709\u6587\u4ef6\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">git add .<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u628a\u5f53\u524d\u76ee\u5f55\u4e0b\u7684\u6240\u6709\u6587\u4ef6\u548c\u5b50\u76ee\u5f55\u6dfb\u52a0\u5230\u6682\u5b58\u533a\u3002<\/p>\n<\/p>\n<p><h2>3.2\u3001\u68c0\u67e5\u6682\u5b58\u533a\u72b6\u6001<\/h2>\n<\/p>\n<p><p>\u5728\u6dfb\u52a0\u6587\u4ef6\u5230\u6682\u5b58\u533a\u540e\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u68c0\u67e5\u6682\u5b58\u533a\u7684\u72b6\u6001\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">git status<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u663e\u793a\u54ea\u4e9b\u6587\u4ef6\u5df2\u7ecf\u88ab\u6dfb\u52a0\u5230\u6682\u5b58\u533a\uff0c\u54ea\u4e9b\u6587\u4ef6\u8fd8\u6ca1\u6709\u88ab\u8ddf\u8e2a\uff0c\u4ee5\u53ca\u54ea\u4e9b\u6587\u4ef6\u6709\u672a\u63d0\u4ea4\u7684\u66f4\u6539\u3002<\/p>\n<\/p>\n<h2><strong>\u56db\u3001\u63d0\u4ea4\u66f4\u6539<\/strong><\/h2>\n<p><p>\u5c06\u6587\u4ef6\u6dfb\u52a0\u5230\u6682\u5b58\u533a\u540e\uff0c\u4f60\u9700\u8981\u63d0\u4ea4\u8fd9\u4e9b\u66f4\u6539\u4ee5\u8bb0\u5f55\u5b83\u4eec\u7684\u5386\u53f2\u3002<\/p>\n<\/p>\n<p><h2>4.1\u3001\u63d0\u4ea4\u5230\u672c\u5730\u4ed3\u5e93<\/h2>\n<\/p>\n<p><p>\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u63d0\u4ea4\u6682\u5b58\u533a\u7684\u66f4\u6539\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">git commit -m &quot;\u4f60\u7684\u63d0\u4ea4\u4fe1\u606f&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u63d0\u4ea4\u4fe1\u606f\u5e94\u8be5\u7b80\u6d01\u660e\u4e86\uff0c\u63cf\u8ff0\u6240\u505a\u7684\u66f4\u6539\u3002<\/p>\n<\/p>\n<p><h2>4.2\u3001\u67e5\u770b\u63d0\u4ea4\u5386\u53f2<\/h2>\n<\/p>\n<p><p>\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u63d0\u4ea4\u5386\u53f2\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">git log<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u663e\u793a\u6240\u6709\u63d0\u4ea4\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u5305\u62ec\u63d0\u4ea4ID\u3001\u4f5c\u8005\u3001\u65e5\u671f\u548c\u63d0\u4ea4\u4fe1\u606f\u3002<\/p>\n<\/p>\n<h2><strong>\u4e94\u3001\u8bbe\u7f6e\u8fdc\u7a0b\u4ed3\u5e93<\/strong><\/h2>\n<p><p>\u5982\u679c\u4f60\u9700\u8981\u4e0e\u5176\u4ed6\u4eba\u5171\u4eab\u9879\u76ee\uff0c\u6216\u8005\u5728\u4e0d\u540c\u7684\u8bbe\u5907\u4e4b\u95f4\u540c\u6b65\u9879\u76ee\uff0c\u4f60\u9700\u8981\u5c06\u672c\u5730\u4ed3\u5e93\u8fde\u63a5\u5230\u4e00\u4e2a\u8fdc\u7a0b\u4ed3\u5e93\u3002<\/p>\n<\/p>\n<p><h2>5.1\u3001\u6dfb\u52a0\u8fdc\u7a0b\u4ed3\u5e93<\/h2>\n<\/p>\n<p><p>\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6dfb\u52a0\u4e00\u4e2a\u8fdc\u7a0b\u4ed3\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">git remote add origin https:\/\/github.com\/user\/repository.git<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><code>origin<\/code>\u662f\u8fdc\u7a0b\u4ed3\u5e93\u7684\u9ed8\u8ba4\u540d\u79f0\uff0c\u4f60\u53ef\u4ee5\u6839\u636e\u9700\u8981\u66f4\u6539\u4e3a\u5176\u4ed6\u540d\u79f0\u3002<\/p>\n<\/p>\n<p><h2>5.2\u3001\u63a8\u9001\u5230\u8fdc\u7a0b\u4ed3\u5e93<\/h2>\n<\/p>\n<p><p>\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5c06\u672c\u5730\u4ed3\u5e93\u7684\u66f4\u6539\u63a8\u9001\u5230\u8fdc\u7a0b\u4ed3\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">git push -u origin master<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><code>master<\/code>\u662f\u4e3b\u5206\u652f\u7684\u540d\u79f0\uff0c\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f\u5176\u4ed6\u5206\u652f\u540d\u79f0\uff0c\u8bf7\u76f8\u5e94\u66f4\u6539\u3002<\/p>\n<\/p>\n<h2><strong>\u516d\u3001\u5206\u652f\u7ba1\u7406<\/strong><\/h2>\n<p><p>\u5206\u652f\u662fGit\u4e2d\u4e00\u4e2a\u975e\u5e38\u5f3a\u5927\u7684\u529f\u80fd\uff0c\u5141\u8bb8\u4f60\u5728\u4e0d\u5f71\u54cd\u4e3b\u5206\u652f\u7684\u60c5\u51b5\u4e0b\u8fdb\u884c\u5b9e\u9a8c\u3002<\/p>\n<\/p>\n<p><h2>6.1\u3001\u521b\u5efa\u5206\u652f<\/h2>\n<\/p>\n<p><p>\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5206\u652f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">git branch new-branch<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>6.2\u3001\u5207\u6362\u5206\u652f<\/h2>\n<\/p>\n<p><p>\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5207\u6362\u5230\u65b0\u7684\u5206\u652f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">git checkout new-branch<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>6.3\u3001\u5408\u5e76\u5206\u652f<\/h2>\n<\/p>\n<p><p>\u5f53\u4f60\u5b8c\u6210\u4e86\u5728\u65b0\u5206\u652f\u4e0a\u7684\u5de5\u4f5c\u540e\uff0c\u53ef\u4ee5\u5c06\u66f4\u6539\u5408\u5e76\u56de\u4e3b\u5206\u652f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">git checkout master<\/p>\n<p>git merge new-branch<\/p>\n<p><\/code><\/pre>\n<\/p>\n<h2><strong>\u4e03\u3001\u89e3\u51b3\u51b2\u7a81<\/strong><\/h2>\n<p><p>\u5728\u591a\u4eba\u534f\u4f5c\u7684\u9879\u76ee\u4e2d\uff0c\u51b2\u7a81\u662f\u4e0d\u53ef\u907f\u514d\u7684\u3002\u5f53\u4e24\u4e2a\u6216\u591a\u4e2a\u5f00\u53d1\u8005\u540c\u65f6\u4fee\u6539\u540c\u4e00\u6587\u4ef6\u65f6\uff0c\u5c31\u4f1a\u4ea7\u751f\u51b2\u7a81\u3002<\/p>\n<\/p>\n<p><h2>7.1\u3001\u8bc6\u522b\u51b2\u7a81<\/h2>\n<\/p>\n<p><p>\u5f53\u4f60\u5c1d\u8bd5\u5408\u5e76\u5206\u652f\u6216\u8005\u62c9\u53d6\u8fdc\u7a0b\u4ed3\u5e93\u7684\u66f4\u6539\u65f6\uff0c\u5982\u679c\u5b58\u5728\u51b2\u7a81\uff0cGit\u4f1a\u901a\u77e5\u4f60\u5e76\u6807\u8bb0\u51b2\u7a81\u7684\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><h2>7.2\u3001\u89e3\u51b3\u51b2\u7a81<\/h2>\n<\/p>\n<p><p>\u4f60\u9700\u8981\u624b\u52a8\u7f16\u8f91\u51b2\u7a81\u7684\u6587\u4ef6\u6765\u89e3\u51b3\u51b2\u7a81\u3002Git\u4f1a\u5728\u51b2\u7a81\u7684\u4f4d\u7f6e\u63d2\u5165\u7279\u6b8a\u7684\u6807\u8bb0\uff0c\u4f60\u53ef\u4ee5\u6839\u636e\u9700\u8981\u9009\u62e9\u4fdd\u7559\u7684\u66f4\u6539\u3002<\/p>\n<\/p>\n<p><h2>7.3\u3001\u63d0\u4ea4\u89e3\u51b3\u540e\u7684\u66f4\u6539<\/h2>\n<\/p>\n<p><p>\u89e3\u51b3\u51b2\u7a81\u540e\uff0c\u4f60\u9700\u8981\u5c06\u89e3\u51b3\u540e\u7684\u6587\u4ef6\u6dfb\u52a0\u5230\u6682\u5b58\u533a\u5e76\u63d0\u4ea4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">git add resolved-file<\/p>\n<p>git commit -m &quot;\u89e3\u51b3\u51b2\u7a81&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<h2><strong>\u516b\u3001\u4f7f\u7528GitHub\u8fdb\u884c\u534f\u4f5c<\/strong><\/h2>\n<p><p>GitHub\u662f\u4e00\u4e2a\u57fa\u4e8eGit\u7684\u4ee3\u7801\u6258\u7ba1\u5e73\u53f0\uff0c\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u534f\u4f5c\u529f\u80fd\u3002<\/p>\n<\/p>\n<p><h2>8.1\u3001\u521b\u5efaGitHub\u4ed3\u5e93<\/h2>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u4f60\u9700\u8981\u5728GitHub\u4e0a\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u4ed3\u5e93\u3002\u5728GitHub\u7f51\u7ad9\u4e0a\u767b\u5f55\u4f60\u7684\u8d26\u6237\uff0c\u70b9\u51fb\u201cNew repository\u201d\u6309\u94ae\uff0c\u586b\u5199\u4ed3\u5e93\u540d\u79f0\u548c\u63cf\u8ff0\uff0c\u7136\u540e\u70b9\u51fb\u201cCreate repository\u201d\u6309\u94ae\u3002<\/p>\n<\/p>\n<p><h2>8.2\u3001\u63a8\u9001\u5230GitHub\u4ed3\u5e93<\/h2>\n<\/p>\n<p><p>\u5728\u672c\u5730\u4ed3\u5e93\u4e2d\uff0c\u6dfb\u52a0GitHub\u4ed3\u5e93\u4e3a\u8fdc\u7a0b\u4ed3\u5e93\uff0c\u5e76\u63a8\u9001\u66f4\u6539\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">git remote add origin https:\/\/github.com\/user\/repository.git<\/p>\n<p>git push -u origin master<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>8.3\u3001\u521b\u5efaPull Request<\/h2>\n<\/p>\n<p><p>\u5728GitHub\u4e0a\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u521b\u5efaPull Request\u6765\u8bf7\u6c42\u5408\u5e76\u4f60\u7684\u66f4\u6539\u3002\u8fdb\u5165\u4f60\u7684\u4ed3\u5e93\uff0c\u70b9\u51fb\u201cNew pull request\u201d\u6309\u94ae\uff0c\u9009\u62e9\u8981\u5408\u5e76\u7684\u5206\u652f\u548c\u76ee\u6807\u5206\u652f\uff0c\u7136\u540e\u586b\u5199\u63cf\u8ff0\u4fe1\u606f\u5e76\u63d0\u4ea4Pull Request\u3002<\/p>\n<\/p>\n<p><h2>8.4\u3001\u4ee3\u7801\u8bc4\u5ba1<\/h2>\n<\/p>\n<p><p>\u5176\u4ed6\u56e2\u961f\u6210\u5458\u53ef\u4ee5\u5bf9Pull Request\u8fdb\u884c\u4ee3\u7801\u8bc4\u5ba1\uff0c\u63d0\u51fa\u610f\u89c1\u548c\u5efa\u8bae\u3002\u4f60\u53ef\u4ee5\u6839\u636e\u8bc4\u5ba1\u610f\u89c1\u8fdb\u884c\u4fee\u6539\uff0c\u76f4\u5230Pull Request\u88ab\u5408\u5e76\u3002<\/p>\n<\/p>\n<h2><strong>\u4e5d\u3001\u5e38\u89c1Git\u547d\u4ee4<\/strong><\/h2>\n<p><p>\u4e3a\u4e86\u66f4\u9ad8\u6548\u5730\u4f7f\u7528Git\uff0c\u4f60\u9700\u8981\u638c\u63e1\u4e00\u4e9b\u5e38\u89c1\u7684Git\u547d\u4ee4\u3002<\/p>\n<\/p>\n<p><h2>9.1\u3001\u67e5\u770b\u5f53\u524d\u5206\u652f<\/h2>\n<\/p>\n<p><pre><code class=\"language-sh\">git branch<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>9.2\u3001\u5220\u9664\u5206\u652f<\/h2>\n<\/p>\n<p><pre><code class=\"language-sh\">git branch -d branch-name<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>9.3\u3001\u67e5\u770b\u8fdc\u7a0b\u4ed3\u5e93<\/h2>\n<\/p>\n<p><pre><code class=\"language-sh\">git remote -v<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>9.4\u3001\u62c9\u53d6\u8fdc\u7a0b\u4ed3\u5e93\u7684\u66f4\u6539<\/h2>\n<\/p>\n<p><pre><code class=\"language-sh\">git pull origin master<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>9.5\u3001\u67e5\u770b\u66f4\u6539<\/h2>\n<\/p>\n<p><pre><code class=\"language-sh\">git diff<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u4e0a\u8ff0\u6b65\u9aa4\uff0c\u4f60\u53ef\u4ee5\u6210\u529f\u5730\u5c06\u9879\u76ee\u7eb3\u5165Git\u7ba1\u7406\uff0c\u5e76\u5229\u7528Git\u7684\u5f3a\u5927\u529f\u80fd\u6765\u8fdb\u884c\u7248\u672c\u63a7\u5236\u548c\u534f\u4f5c\u3002\u5e0c\u671b\u8fd9\u7bc7\u6587\u7ae0\u80fd\u591f\u5e2e\u52a9\u4f60\u66f4\u597d\u5730\u7406\u89e3\u548c\u4f7f\u7528Git\u8fdb\u884c<a href=\"https:\/\/docs.pingcode.com\/blog\/project-management\/23316.html\" target=\"_blank\">\u9879\u76ee\u7ba1\u7406<\/a>\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>1. \u6211\u8be5\u5982\u4f55\u5c06\u9879\u76ee\u6dfb\u52a0\u5230Git\u7248\u672c\u63a7\u5236\u4e2d\uff1f<\/strong><\/p>\n<p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u5728\u9879\u76ee\u7684\u6839\u76ee\u5f55\u4e2d\u521d\u59cb\u5316\u4e00\u4e2aGit\u4ed3\u5e93\u3002\u5728\u547d\u4ee4\u884c\u4e2d\uff0c\u5bfc\u822a\u5230\u9879\u76ee\u76ee\u5f55\u5e76\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<code>git init<\/code><\/p>\n<p>\u7136\u540e\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528<code>git add<\/code>\u547d\u4ee4\u5c06\u9879\u76ee\u7684\u6587\u4ef6\u6dfb\u52a0\u5230Git\u7684\u6682\u5b58\u533a\u3002\u4f8b\u5982\uff0c\u8981\u5c06\u6240\u6709\u6587\u4ef6\u6dfb\u52a0\u5230\u6682\u5b58\u533a\uff0c\u53ef\u4ee5\u8fd0\u884c\uff1a<code>git add .<\/code><\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u4f7f\u7528<code>git commit<\/code>\u547d\u4ee4\u5c06\u6682\u5b58\u533a\u7684\u6587\u4ef6\u63d0\u4ea4\u5230Git\u4ed3\u5e93\u4e2d\u3002\u4f8b\u5982\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<code>git commit -m &quot;Initial commit&quot;<\/code><\/p>\n<p>\u73b0\u5728\uff0c\u60a8\u7684\u9879\u76ee\u5df2\u7ecf\u88abGit\u7ba1\u7406\u4e86\u3002<\/p>\n<p><strong>2. \u5982\u4f55\u5728Git\u4e2d\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5206\u652f\uff1f<\/strong><\/p>\n<p>\u8981\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5206\u652f\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528<code>git branch<\/code>\u547d\u4ee4\u3002\u4f8b\u5982\uff0c\u8981\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a&quot;feature-branch&quot;\u7684\u5206\u652f\uff0c\u53ef\u4ee5\u8fd0\u884c\uff1a<code>git branch feature-branch<\/code><\/p>\n<p>\u7136\u540e\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528<code>git checkout<\/code>\u547d\u4ee4\u5207\u6362\u5230\u65b0\u521b\u5efa\u7684\u5206\u652f\u3002\u4f8b\u5982\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<code>git checkout feature-branch<\/code><\/p>\n<p>\u73b0\u5728\uff0c\u60a8\u5df2\u7ecf\u5207\u6362\u5230\u4e86\u65b0\u521b\u5efa\u7684\u5206\u652f\uff0c\u53ef\u4ee5\u5728\u8be5\u5206\u652f\u4e0a\u8fdb\u884c\u5f00\u53d1\u5de5\u4f5c\u3002<\/p>\n<p><strong>3. \u5982\u4f55\u5c06\u672c\u5730\u7684Git\u4ed3\u5e93\u4e0e\u8fdc\u7a0b\u4ed3\u5e93\u8fdb\u884c\u5173\u8054\uff1f<\/strong><\/p>\n<p>\u8981\u5c06\u672c\u5730\u7684Git\u4ed3\u5e93\u4e0e\u8fdc\u7a0b\u4ed3\u5e93\u8fdb\u884c\u5173\u8054\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528<code>git remote<\/code>\u547d\u4ee4\u3002\u9996\u5148\uff0c\u60a8\u9700\u8981\u5728\u8fdc\u7a0b\u4ed3\u5e93\u4e2d\u521b\u5efa\u4e00\u4e2a\u7a7a\u7684\u4ed3\u5e93\u3002<\/p>\n<p>\u7136\u540e\uff0c\u5728\u547d\u4ee4\u884c\u4e2d\uff0c\u5bfc\u822a\u5230\u672c\u5730\u7684Git\u4ed3\u5e93\u76ee\u5f55\u5e76\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<code>git remote add origin &lt;\u8fdc\u7a0b\u4ed3\u5e93\u7684URL&gt;<\/code><\/p>\n<p>\u8fd9\u6837\uff0c\u60a8\u5c31\u5c06\u672c\u5730\u7684Git\u4ed3\u5e93\u4e0e\u8fdc\u7a0b\u4ed3\u5e93\u8fdb\u884c\u4e86\u5173\u8054\uff0c\u53ef\u4ee5\u4f7f\u7528<code>git push<\/code>\u547d\u4ee4\u5c06\u672c\u5730\u7684\u63d0\u4ea4\u63a8\u9001\u5230\u8fdc\u7a0b\u4ed3\u5e93\u4e2d\u3002\u4f8b\u5982\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<code>git push -u origin master<\/code><\/p>\n<p>\u73b0\u5728\uff0c\u60a8\u7684\u672c\u5730\u4ed3\u5e93\u4e0e\u8fdc\u7a0b\u4ed3\u5e93\u5df2\u7ecf\u5173\u8054\u6210\u529f\uff0c\u53ef\u4ee5\u8fdb\u884c\u4ee3\u7801\u7684\u5171\u4eab\u548c\u534f\u4f5c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u8ba9\u9879\u76ee\u88abGit\u7ba1\u7406\uff0c\u4f60\u9700\u8981\uff1a\u521d\u59cb\u5316Git\u4ed3\u5e93\u3001\u6dfb\u52a0\u6587\u4ef6\u5230\u4ed3\u5e93\u3001\u63d0\u4ea4\u66f4\u6539\u3001\u8bbe\u7f6e\u8fdc\u7a0b\u4ed3\u5e93\u3002 \u5176\u4e2d\u6700\u91cd\u8981\u7684\u4e00\u70b9\u662f\u521d [&hellip;]","protected":false},"author":3,"featured_media":344783,"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\/344755"}],"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=344755"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/344755\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/344783"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=344755"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=344755"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=344755"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}