{"id":530254,"date":"2024-06-05T10:58:51","date_gmt":"2024-06-05T02:58:51","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/530254.html"},"modified":"2024-06-05T10:59:02","modified_gmt":"2024-06-05T02:59:02","slug":"%e5%a6%82%e4%bd%95%e5%b0%86%e9%a1%b9%e7%9b%ae%e5%8a%a0%e5%88%b0%e6%ba%90%e4%bb%a3%e7%a0%81%e7%ae%a1%e7%90%86","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/530254.html","title":{"rendered":"\u5982\u4f55\u5c06\u9879\u76ee\u52a0\u5230\u6e90\u4ee3\u7801\u7ba1\u7406"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24210547\/7bcdbf1f-8e97-4b6d-b2b2-ae0c4d0734d2.webp\" alt=\"\u5982\u4f55\u5c06\u9879\u76ee\u52a0\u5230\u6e90\u4ee3\u7801\u7ba1\u7406\" \/><\/p>\n<p><p>\u5c06\u9879\u76ee\u52a0\u5230\u6e90\u4ee3\u7801\u7ba1\u7406\u662f\u4e00\u4e2a\u91cd\u8981\u7684\u6b65\u9aa4\uff0c\u7528\u4e8e\u8ddf\u8e2a\u548c\u63a7\u5236\u8f6f\u4ef6\u5f00\u53d1\u8fc7\u7a0b\u4e2d\u7684\u7248\u672c\u53d8\u5316\u3002<strong>\u6700\u5e38\u89c1\u7684\u6e90\u4ee3\u7801\u7ba1\u7406\u5de5\u5177\u5305\u62ecGit\u3001Subversion\uff08SVN\uff09\u548cMercurial<\/strong>\u3002\u672c\u6587\u5c06\u4ee5<strong>Git<\/strong>\u4e3a\u4f8b\u8be6\u7ec6\u8bb2\u89e3\u5982\u4f55\u5c06\u9879\u76ee\u52a0\u5230\u6e90\u4ee3\u7801\u7ba1\u7406\uff0c\u56e0\u4e3aGit\u662f\u76ee\u524d\u6700\u6d41\u884c\u7684\u6e90\u4ee3\u7801\u7ba1\u7406\u5de5\u5177\u4e4b\u4e00\uff0c\u5b83\u5177\u6709\u5f3a\u5927\u7684\u5206\u652f\u7ba1\u7406\u7cfb\u7edf\u3001\u8fdc\u7a0b\u534f\u4f5c\u529f\u80fd\u548c\u9ad8\u6548\u7684\u6027\u80fd\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u5b89\u88c5GIT<\/h3>\n<\/p>\n<p><p>\u5728\u5c06\u9879\u76ee\u52a0\u5165\u6e90\u4ee3\u7801\u7ba1\u7406\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u5728\u4f60\u7684\u673a\u5668\u4e0a\u5b89\u88c5Git\u3002Git\u7684\u5b89\u88c5\u8fc7\u7a0b\u76f8\u5bf9\u7b80\u5355\uff0c\u53ef\u4ee5\u4eceGit\u7684\u5b98\u7f51\u4e0b\u8f7d\u5bf9\u5e94\u64cd\u4f5c\u7cfb\u7edf\u7684\u5b89\u88c5\u5305\u3002<\/p>\n<\/p>\n<ul>\n<li><strong>Windows\u7cfb\u7edf<\/strong>\uff1a\u4e0b\u8f7dGit\u540e\uff0c\u8fd0\u884c\u5b89\u88c5\u7a0b\u5e8f\u5e76\u6309\u7167\u5411\u5bfc\u6307\u793a\u5b8c\u6210\u5b89\u88c5\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u53f3\u952e\u70b9\u51fb\u4efb\u610f\u6587\u4ef6\u5939\u9009\u62e9\u201cGit Bash Here\u201d\u6765\u6253\u5f00Git\u547d\u4ee4\u884c\u754c\u9762\u3002<\/li>\n<li><strong>Mac\u7cfb\u7edf<\/strong>\uff1a\u53ef\u4ee5\u4f7f\u7528Homebrew\u6765\u5b89\u88c5Git\uff0c\u8fd0\u884c\u547d\u4ee4<code>brew install git<\/code>\u5373\u53ef\u3002<\/li>\n<li><strong>Linux\u7cfb\u7edf<\/strong>\uff1a\u5927\u591a\u6570Linux\u53d1\u884c\u7248\u90fd\u5305\u542bGit\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u5305\u7ba1\u7406\u5668\u5b89\u88c5\u3002\u4f8b\u5982\uff0c\u5728Ubuntu\u4e0a\uff0c\u53ef\u4ee5\u4f7f\u7528<code>sudo apt-get install git<\/code>\u547d\u4ee4\u5b89\u88c5\u3002<\/li>\n<\/ul>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6253\u5f00\u7ec8\u7aef\u6216Git Bash\uff0c\u8f93\u5165<code>git --version<\/code>\u6765\u9a8c\u8bc1\u662f\u5426\u5b89\u88c5\u6210\u529f\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u914d\u7f6eGIT<\/h3>\n<\/p>\n<p><p>\u5b89\u88c5Git\u540e\uff0c\u4f60\u9700\u8981\u914d\u7f6e\u4f60\u7684\u7528\u6237\u540d\u548c\u7535\u5b50\u90ae\u4ef6\u5730\u5740\u3002\u8fd9\u4e00\u6b65\u975e\u5e38\u91cd\u8981\uff0c\u56e0\u4e3a\u6bcf\u6b21Git\u63d0\u4ea4\u65f6\u90fd\u4f1a\u4f7f\u7528\u8fd9\u4e9b\u4fe1\u606f\u3002\u6253\u5f00\u7ec8\u7aef\u6216Git Bash\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">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\u4e9b\u4fe1\u606f\u5c06\u88ab\u8bb0\u5f55\u5728Git\u7684\u5168\u5c40\u914d\u7f6e\u6587\u4ef6\u4e2d\u3002\u9664\u6b64\u4e4b\u5916\uff0c\u4f60\u8fd8\u53ef\u4ee5\u6839\u636e\u9700\u8981\u914d\u7f6e\u7f16\u8f91\u5668\u504f\u597d\u3001\u5dee\u5f02\u5206\u6790\u5de5\u5177\u7b49\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u521d\u59cb\u5316\u4ed3\u5e93<\/h3>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u4f60\u9700\u8981\u5728\u9879\u76ee\u76ee\u5f55\u4e2d\u521d\u59cb\u5316Git\u4ed3\u5e93\u3002\u9996\u5148\uff0c\u6253\u5f00\u7ec8\u7aef\u6216Git Bash\uff0c\u5207\u6362\u5230\u4f60\u7684\u9879\u76ee\u76ee\u5f55\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">cd \/path\/to\/your\/project<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u521d\u59cb\u5316\u4ed3\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">git init<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6b64\u547d\u4ee4\u5c06\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a.git\u7684\u9690\u85cf\u76ee\u5f55\uff0c\u8fd9\u4e2a\u76ee\u5f55\u5305\u542b\u4e86\u6240\u6709\u7684Git\u4ed3\u5e93\u6570\u636e\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u6dfb\u52a0\u6587\u4ef6\u5230\u4ed3\u5e93<\/h3>\n<\/p>\n<p><p>\u9879\u76ee\u521d\u59cb\u5316\u540e\uff0c\u4f60\u9700\u8981\u5c06\u9879\u76ee\u6587\u4ef6\u6dfb\u52a0\u5230\u4ed3\u5e93\u4e2d\u3002\u9996\u5148\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528<code>git status<\/code>\u547d\u4ee4\u67e5\u770b\u5f53\u524d\u76ee\u5f55\u4e0b\u7684\u6587\u4ef6\u72b6\u6001\u3002\u7136\u540e\uff0c\u4f7f\u7528<code>git add<\/code>\u547d\u4ee4\u5c06\u6587\u4ef6\u6dfb\u52a0\u5230\u6682\u5b58\u533a\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">git add .<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a\u547d\u4ee4\u4f1a\u5c06\u5f53\u524d\u76ee\u5f55\u4e0b\u7684\u6240\u6709\u6587\u4ef6\u548c\u5b50\u76ee\u5f55\u6dfb\u52a0\u5230\u6682\u5b58\u533a\u3002\u5982\u679c\u4f60\u53ea\u60f3\u6dfb\u52a0\u7279\u5b9a\u6587\u4ef6\uff0c\u53ef\u4ee5\u5c06<code>.<\/code>\u66ff\u6362\u4e3a\u6587\u4ef6\u540d\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u63d0\u4ea4\u66f4\u6539<\/h3>\n<\/p>\n<p><p>\u6587\u4ef6\u6dfb\u52a0\u5230\u6682\u5b58\u533a\u540e\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528<code>git commit<\/code>\u547d\u4ee4\u6765\u63d0\u4ea4\u8fd9\u4e9b\u66f4\u6539\u3002\u6bcf\u6b21\u63d0\u4ea4\u90fd\u4f1a\u8bb0\u5f55\u4e00\u4e2a\u5feb\u7167\uff0c\u4fbf\u4e8e\u4ee5\u540e\u67e5\u770b\u548c\u56de\u9000\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">git commit -m &quot;Initial commit&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u91cc<code>-m<\/code>\u540e\u9762\u8ddf\u7740\u7684\u662f\u63d0\u4ea4\u4fe1\u606f\uff0c\u5b83\u63cf\u8ff0\u4e86\u8fd9\u6b21\u63d0\u4ea4\u7684\u5185\u5bb9\u6216\u76ee\u7684\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001\u8fde\u63a5\u8fdc\u7a0b\u4ed3\u5e93<\/h3>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u60f3\u548c\u56e2\u961f\u6210\u5458\u5171\u4eab\u9879\u76ee\uff0c\u6216\u8005\u5907\u4efd\u4f60\u7684\u4ee3\u7801\u5230\u8fdc\u7a0b\u670d\u52a1\u5668\uff0c\u4f60\u9700\u8981\u5c06\u672c\u5730\u4ed3\u5e93\u8fde\u63a5\u5230\u8fdc\u7a0b\u4ed3\u5e93\u3002GitHub\u3001GitLab\u548cBitbucket\u662f\u5e38\u89c1\u7684\u8fdc\u7a0b\u4ed3\u5e93\u6258\u7ba1\u670d\u52a1\u3002<\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u5728\u8fdc\u7a0b\u4ed3\u5e93\u670d\u52a1\u4e0a\u521b\u5efa\u4e00\u4e2a\u65b0\u4ed3\u5e93\uff0c\u7136\u540e\u83b7\u53d6\u4ed3\u5e93\u7684URL\u3002\u63a5\u7740\uff0c\u56de\u5230\u7ec8\u7aef\u6216Git Bash\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u6dfb\u52a0\u8fdc\u7a0b\u4ed3\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">git remote add origin &lt;repository-url&gt;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u91cc<code>origin<\/code>\u662f\u8fdc\u7a0b\u4ed3\u5e93\u7684\u9ed8\u8ba4\u540d\u79f0\uff0c<code>&lt;repository-url&gt;<\/code>\u662f\u4f60\u7684\u8fdc\u7a0b\u4ed3\u5e93\u5730\u5740\u3002<\/p>\n<\/p>\n<p><h3>\u4e03\u3001\u63a8\u9001\u5230\u8fdc\u7a0b\u4ed3\u5e93<\/h3>\n<\/p>\n<p><p>\u6dfb\u52a0\u8fdc\u7a0b\u4ed3\u5e93\u540e\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528<code>git push<\/code>\u547d\u4ee4\u5c06\u4ee3\u7801\u63a8\u9001\u5230\u8fdc\u7a0b\u4ed3\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">git push -u origin master<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u91cc<code>-u<\/code>\u53c2\u6570\u6307\u5b9a\u4e86\u5c06\u672c\u5730\u7684<code>master<\/code>\u5206\u652f\u63a8\u9001\u5230<code>origin<\/code>\u8fdc\u7a0b\u4ed3\u5e93\uff0c\u5e76\u5efa\u7acb\u8ddf\u8e2a\u5173\u7cfb\uff0c\u4ee5\u4fbf\u672a\u6765\u7684\u63a8\u9001\u53ef\u4ee5\u7b80\u5316\u547d\u4ee4\u3002<\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u4f60\u7684\u9879\u76ee\u5c31\u6210\u529f\u52a0\u5165\u4e86\u6e90\u4ee3\u7801\u7ba1\u7406\u3002\u8fd9\u4e2a\u8fc7\u7a0b\u4e0d\u4ec5\u5e2e\u52a9\u4f60\u8ddf\u8e2a\u9879\u76ee\u7684\u7248\u672c\u5386\u53f2\uff0c\u8fd8\u4fbf\u4e8e\u56e2\u961f\u534f\u4f5c\u548c\u4ee3\u7801\u5171\u4eab\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>1. \u4e3a\u4ec0\u4e48\u6211\u9700\u8981\u5c06\u9879\u76ee\u52a0\u5230\u6e90\u4ee3\u7801\u7ba1\u7406\uff1f<\/strong><br \/>\n\u6e90\u4ee3\u7801\u7ba1\u7406\u662f\u4e00\u79cd\u6709\u6548\u7684\u65b9\u5f0f\u6765\u8ddf\u8e2a\u3001\u7ba1\u7406\u548c\u534f\u4f5c\u5f00\u53d1\u9879\u76ee\u7684\u4ee3\u7801\u3002\u5b83\u53ef\u4ee5\u5e2e\u52a9\u60a8\u8ffd\u8e2a\u4ee3\u7801\u7684\u53d8\u66f4\u5386\u53f2\uff0c\u6062\u590d\u4e4b\u524d\u7684\u7248\u672c\uff0c\u4ee5\u53ca\u4e0e\u56e2\u961f\u6210\u5458\u8fdb\u884c\u534f\u4f5c\u3002\u901a\u8fc7\u5c06\u9879\u76ee\u52a0\u5165\u6e90\u4ee3\u7801\u7ba1\u7406\uff0c\u60a8\u53ef\u4ee5\u66f4\u597d\u5730\u7ec4\u7ec7\u548c\u4fdd\u62a4\u60a8\u7684\u4ee3\u7801\u3002<\/p>\n<p><strong>2. \u5982\u4f55\u9009\u62e9\u9002\u5408\u6211\u9879\u76ee\u7684\u6e90\u4ee3\u7801\u7ba1\u7406\u5de5\u5177\uff1f<\/strong><br \/>\n\u9009\u62e9\u9002\u5408\u60a8\u9879\u76ee\u7684\u6e90\u4ee3\u7801\u7ba1\u7406\u5de5\u5177\u53ef\u4ee5\u6839\u636e\u9879\u76ee\u7684\u7279\u70b9\u548c\u9700\u6c42\u6765\u51b3\u5b9a\u3002\u5e38\u89c1\u7684\u6e90\u4ee3\u7801\u7ba1\u7406\u5de5\u5177\u5305\u62ecGit\u3001Subversion\u548cMercurial\u7b49\u3002\u60a8\u53ef\u4ee5\u6839\u636e\u60a8\u5bf9\u5de5\u5177\u7684\u719f\u6089\u7a0b\u5ea6\u3001\u56e2\u961f\u7684\u89c4\u6a21\u548c\u5206\u5e03\u3001\u9879\u76ee\u7684\u590d\u6742\u6027\u7b49\u56e0\u7d20\u6765\u9009\u62e9\u5408\u9002\u7684\u5de5\u5177\u3002<\/p>\n<p><strong>3. \u5982\u4f55\u5c06\u9879\u76ee\u52a0\u5230Git\u6e90\u4ee3\u7801\u7ba1\u7406\uff1f<\/strong><br \/>\n\u5c06\u9879\u76ee\u52a0\u5165Git\u6e90\u4ee3\u7801\u7ba1\u7406\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\uff1a<\/p>\n<ul>\n<li>\u5728\u672c\u5730\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Git\u4ed3\u5e93\u3002<\/li>\n<li>\u5c06\u9879\u76ee\u7684\u6587\u4ef6\u548c\u6587\u4ef6\u5939\u590d\u5236\u5230Git\u4ed3\u5e93\u4e2d\u3002<\/li>\n<li>\u4f7f\u7528\u547d\u4ee4\u884c\u6216Git\u5ba2\u6237\u7aef\u6267\u884cgit add\u547d\u4ee4\u5c06\u9879\u76ee\u6587\u4ef6\u6dfb\u52a0\u5230\u4ed3\u5e93\u3002<\/li>\n<li>\u6267\u884cgit commit\u547d\u4ee4\u63d0\u4ea4\u9879\u76ee\u7684\u66f4\u6539\u3002<\/li>\n<li>\u5982\u679c\u9700\u8981\uff0c\u53ef\u4ee5\u5c06\u672c\u5730\u4ed3\u5e93\u4e0e\u8fdc\u7a0b\u4ed3\u5e93\u8fdb\u884c\u5173\u8054\uff0c\u5e76\u5c06\u66f4\u6539\u63a8\u9001\u5230\u8fdc\u7a0b\u4ed3\u5e93\u3002<\/li>\n<\/ul>\n<p>\u8bf7\u6ce8\u610f\uff0c\u4ee5\u4e0a\u6b65\u9aa4\u4ec5\u63d0\u4f9b\u4e86\u4e00\u4e2a\u57fa\u672c\u7684\u64cd\u4f5c\u6d41\u7a0b\uff0c\u5177\u4f53\u7684\u7ec6\u8282\u548c\u547d\u4ee4\u53ef\u80fd\u4f1a\u56e0\u4f7f\u7528\u7684\u5de5\u5177\u548c\u64cd\u4f5c\u7cfb\u7edf\u800c\u6709\u6240\u4e0d\u540c\u3002\u5efa\u8bae\u60a8\u53c2\u8003\u76f8\u5173\u7684\u6587\u6863\u6216\u6559\u7a0b\u6765\u4e86\u89e3\u66f4\u8be6\u7ec6\u7684\u6b65\u9aa4\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5c06\u9879\u76ee\u52a0\u5230\u6e90\u4ee3\u7801\u7ba1\u7406\u662f\u4e00\u4e2a\u91cd\u8981\u7684\u6b65\u9aa4\uff0c\u7528\u4e8e\u8ddf\u8e2a\u548c\u63a7\u5236\u8f6f\u4ef6\u5f00\u53d1\u8fc7\u7a0b\u4e2d\u7684\u7248\u672c\u53d8\u5316\u3002\u6700\u5e38\u89c1\u7684\u6e90\u4ee3\u7801\u7ba1\u7406\u5de5\u5177\u5305\u62ecGit [&hellip;]","protected":false},"author":3,"featured_media":530261,"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\/530254"}],"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=530254"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/530254\/revisions"}],"predecessor-version":[{"id":530265,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/530254\/revisions\/530265"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/530261"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=530254"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=530254"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=530254"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}