{"id":140,"date":"2026-01-31T17:56:12","date_gmt":"2026-01-31T09:56:12","guid":{"rendered":"http:\/\/muse.lzink.icu\/?p=140"},"modified":"2026-01-29T17:56:37","modified_gmt":"2026-01-29T09:56:37","slug":"%e5%88%ab%e8%ae%a9%e4%bd%a0%e7%9a%84%e4%bb%a3%e7%a0%81%e8%a3%b8%e5%a5%94%ef%bc%9agit-%e8%bf%9c%e7%a8%8b%e4%bb%93%e5%ba%93%e5%a4%87%e4%bb%bd%e6%8c%87%e5%8d%97","status":"publish","type":"post","link":"https:\/\/muse.lzink.icu\/?p=140","title":{"rendered":"\u522b\u8ba9\u4f60\u7684\u4ee3\u7801\u201c\u88f8\u5954\u201d\uff1aGit \u8fdc\u7a0b\u4ed3\u5e93\u5907\u4efd\u6307\u5357"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u4f5c\u4e3a\u5f00\u53d1\u8005\uff0c\u6211\u4eec\u6700\u5b9d\u8d35\u7684\u8d44\u4ea7\u5c31\u662f\u4ee3\u7801\u3002\u5f88\u591a\u4eba\u4e60\u60ef\u4e8e\u672c\u5730\u5f00\u53d1\uff0c\u4f46\u5982\u679c\u7f3a\u4e4f\u8fdc\u7a0b\u5907\u4efd\uff0c\u4e00\u65e6\u906d\u9047\u786c\u4ef6\u6545\u969c\u6216\u8bef\u64cd\u4f5c\uff0c\u635f\u5931\u5f80\u5f80\u662f\u707e\u96be\u6027\u7684\u3002Git \u4e0d\u4ec5\u662f\u7248\u672c\u63a7\u5236\u5de5\u5177\uff0c\u66f4\u662f\u9879\u76ee\u6700\u7a33\u59a5\u7684\u201c\u4fdd\u9669\u7bb1\u201d\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4eca\u5929\u5206\u4eab\u4e00\u5957\u6700\u6807\u51c6\u3001\u6700\u5b9e\u7528\u7684 Git \u5907\u4efd\u6d41\u7a0b\uff0c\u5e2e\u5927\u5bb6\u5feb\u901f\u6784\u5efa\u8d77\u4ece\u672c\u5730\u5230\u8fdc\u7a0b\u7684\u540c\u6b65\u65b9\u6848\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. \u5efa\u7acb\u9632\u7ebf\uff1a\u521d\u59cb\u5316\u672c\u5730\u4ed3\u5e93<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u786e\u4fdd\u4f60\u5df2\u7ecf\u5b89\u88c5\u4e86 Git\u3002\u8fdb\u5165\u4f60\u7684\u9879\u76ee\u6839\u76ee\u5f55\uff0c\u6253\u5f00\u7ec8\u7aef\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u521d\u59cb\u5316\uff1a<\/strong> \u544a\u8bc9 Git \u8fd9\u4e2a\u76ee\u5f55\u9700\u8981\u88ab\u7ba1\u7406\u3002Bashgit init<\/li>\n\n\n\n<li><strong>\u6784\u5efa\u8fc7\u6ee4\u7f51\uff1a<\/strong> \u8fd9\u662f\u4e00\u4e2a\u65b0\u624b\u6781\u6613\u5ffd\u7565\u7684\u7ec6\u8282\u3002\u4e00\u5b9a\u8981\u5728\u6839\u76ee\u5f55\u521b\u5efa\u4e00\u4e2a <code>.gitignore<\/code> \u6587\u4ef6\uff0c\u628a\u4e0d\u9700\u8981\u4e0a\u4f20\u7684\u201c\u5783\u573e\u201d\u8fc7\u6ee4\u6389\uff08\u5982 <code>node_modules<\/code>\u3001\u73af\u5883\u53d8\u91cf\u6587\u4ef6 <code>.env<\/code>\u3001\u65e5\u5fd7\u6587\u4ef6\u7b49\uff09\u3002<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">2. \u5b58\u6863\u7ba1\u7406\uff1a\u4ece\u5de5\u4f5c\u533a\u5230\u672c\u5730\u4ed3\u5e93<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728 Git \u7684\u903b\u8f91\u91cc\uff0c\u4ee3\u7801\u4e0a\u4f20\u4e0d\u662f\u4e00\u6b65\u5230\u4f4d\u7684\uff0c\u8fd9\u79cd\u8bbe\u8ba1\u662f\u4e3a\u4e86\u8ba9\u4f60\u80fd\u591f\u7cbe\u786e\u63a7\u5236\u6bcf\u4e00\u6b21\u201c\u5b58\u6863\u201d\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u7b2c\u4e00\u6b65\uff08\u88c5\u7bb1\uff09\uff1a<\/strong> \u5c06\u6240\u6709\u4fee\u6539\u8fc7\u7684\u6587\u4ef6\u6dfb\u52a0\u5230\u6682\u5b58\u533a\u3002Bashgit add .<\/li>\n\n\n\n<li><strong>\u7b2c\u4e8c\u6b65\uff08\u8d34\u6807\u7b7e\uff09\uff1a<\/strong> \u63d0\u4ea4\u5230\u672c\u5730\u4ed3\u5e93\uff0c\u5e76\u8bf4\u660e\u8fd9\u6b21\u6539\u4e86\u4ec0\u4e48\u3002Bashgit commit -m &#8220;feat: \u521d\u59cb\u9879\u76ee\u642d\u5efa\u53ca\u57fa\u7840\u529f\u80fd\u5b9e\u73b0&#8221;<strong>\u7ecf\u9a8c\u4e4b\u8c08\uff1a<\/strong> \u63d0\u4ea4\u4fe1\u606f\uff08Commit Message\uff09\u5efa\u8bae\u9075\u5faa\u89c4\u8303\uff08\u5982 <code>feat:<\/code> \u8868\u793a\u65b0\u529f\u80fd\uff0c<code>fix:<\/code> \u8868\u793a\u4fee Bug\uff09\uff0c\u8fd9\u4e0d\u4ec5\u662f\u4e3a\u4e86\u6574\u6d01\uff0c\u66f4\u662f\u4e3a\u4e86\u4ee5\u540e\u56de\u6eaf\u4ee3\u7801\u65f6\u80fd\u4e00\u773c\u770b\u6e05\u8109\u7edc\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">3. \u8fdc\u7a0b\u8fde\u63a5\uff1a\u5728\u4e91\u7aef\u5b89\u5bb6<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u63a5\u4e0b\u6765\uff0c\u4f60\u9700\u8981\u5728 GitHub\u3001GitLab \u6216 Gitee \u4e0a\u521b\u5efa\u4e00\u4e2a\u65b0\u4ed3\u5e93\u3002\u62ff\u5230\u4ed3\u5e93\u5730\u5740\uff08HTTPS \u6216 SSH\uff09\u540e\uff0c\u6267\u884c\u4ee5\u4e0b\u64cd\u4f5c\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u5efa\u7acb\u5173\u8054\uff1a<\/strong> \u5c06\u672c\u5730\u4ed3\u5e93\u4e0e\u8fdc\u7a0b\u4ed3\u5e93\u5730\u5740\u7ed1\u5b9a\u3002Bashgit remote add origin https:\/\/github.com\/\u7528\u6237\u540d\/\u4ed3\u5e93\u540d.git<\/li>\n\n\n\n<li><strong>\u9996\u6b21\u63a8\u9001\uff1a<\/strong> \u628a\u672c\u5730\u4ee3\u7801\u63a8\u9001\u5230\u8fdc\u7a0b\u670d\u52a1\u5668\u3002Bashgit push -u origin main<code>-u<\/code> \u53c2\u6570\u53ea\u9700\u7b2c\u4e00\u6b21\u4f7f\u7528\uff0c\u5b83\u4f1a\u5efa\u7acb\u8d77\u672c\u5730\u5206\u652f\u4e0e\u8fdc\u7a0b\u5206\u652f\u7684\u8ffd\u8e2a\u5173\u7cfb\uff0c\u4ee5\u540e\u76f4\u63a5\u8f93\u5165 <code>git push<\/code> \u5c31\u53ef\u4ee5\u4e86\u3002<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">4. \u907f\u5751<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u5b9e\u9645\u64cd\u4f5c\u4e2d\uff0c\u6709\u51e0\u4e2a\u7ec6\u8282\u80fd\u8ba9\u4f60\u5c11\u8d70\u5f2f\u8def\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u9891\u7387\u539f\u5219\uff1a<\/strong> \u4e0d\u8981\u7b49\u9879\u76ee\u5199\u5b8c\u4e86\u624d Push\u3002\u5efa\u8bae\u6bcf\u5b8c\u6210\u4e00\u4e2a\u72ec\u7acb\u7684\u529f\u80fd\u70b9\u6216\u4fee\u590d\u4e00\u4e2a Bug\uff0c\u5c31\u8fdb\u884c\u4e00\u6b21\u5b8c\u6574\u7684 Commit \u548c Push\u3002<\/li>\n\n\n\n<li><strong>\u5b89\u5168\u6027\uff1a<\/strong> \u6c38\u8fdc\u4e0d\u8981\u628a\u6570\u636e\u5e93\u5bc6\u7801\u3001API \u5bc6\u94a5\u76f4\u63a5\u5199\u5728\u4ee3\u7801\u91cc\u5e76\u4f20\u5230\u516c\u5171\u4ed3\u5e93\u3002\u5982\u679c\u5df2\u7ecf\u4f20\u4e0a\u53bb\u4e86\uff0c\u4ec5\u4ec5\u5220\u9664\u662f\u4e0d\u591f\u7684\uff0c\u9700\u8981\u6e05\u7406 Git \u5386\u53f2\u8bb0\u5f55\u6216\u7acb\u5373\u66f4\u6362\u5bc6\u94a5\u3002<\/li>\n\n\n\n<li><strong>\u5206\u652f\u610f\u8bc6\uff1a<\/strong> \u5982\u679c\u662f\u957f\u671f\u5f00\u53d1\uff0c\u5efa\u8bae\u5728 <code>develop<\/code> \u5206\u652f\u5de5\u4f5c\uff0c\u786e\u8ba4\u7a33\u5b9a\u540e\u518d\u5408\u5e76\u5230 <code>main<\/code> \u5206\u652f\u3002<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\u8fdb\u9636\u914d\u7f6e\uff1a\u5b9e\u73b0 SSH \u514d\u5bc6\u4e0a\u4f20\u4ee3\u7801<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">SSH\uff08Secure Shell\uff09\u5907\u4efd\u65b9\u5f0f\u76f8\u6bd4 HTTPS\uff0c\u4e0d\u4ec5\u514d\u53bb\u4e86\u9891\u7e41\u8f93\u5165\u5bc6\u7801\u7684\u7410\u4e8b\uff0c\u800c\u4e14\u5728\u6570\u636e\u4f20\u8f93\u4e0a\u66f4\u52a0\u5b89\u5168\u7a33\u5b9a\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. \u68c0\u67e5\u73b0\u6709\u7684\u5bc6\u94a5<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u751f\u6210\u65b0\u5bc6\u94a5\u4e4b\u524d\uff0c\u5148\u770b\u770b\u4f60\u7535\u8111\u91cc\u662f\u4e0d\u662f\u5df2\u7ecf\u6709\u8fc7\u4e86\u3002\u6253\u5f00\u7ec8\u7aef\u8f93\u5165\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Bash<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ls -al ~\/.ssh<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u4f60\u770b\u5230\u6709 <code>id_rsa.pub<\/code> \u6216\u8005 <code>id_ed25519.pub<\/code>\uff0c\u8bf4\u660e\u4f60\u5df2\u7ecf\u6709\u5bc6\u94a5\u5bf9\uff0c\u53ef\u4ee5\u76f4\u63a5\u8df3\u5230\u7b2c 3 \u6b65\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. \u751f\u6210\u65b0\u7684 SSH \u5bc6\u94a5<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u6ca1\u6709\uff0c\u8fd0\u884c\u4e0b\u9762\u8fd9\u884c\u547d\u4ee4\uff08\u628a\u90ae\u7bb1\u6362\u6210\u4f60\u81ea\u5df1\u7684\uff09\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Bash<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ssh-keygen -t ed25519 -C \"your_email@example.com\"<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u63d0\u793a\u4e00\uff1a<\/strong> \u8be2\u95ee\u4fdd\u5b58\u8def\u5f84\uff0c\u76f4\u63a5\u6309 <strong>\u56de\u8f66<\/strong> \u9ed8\u8ba4\u5373\u53ef\u3002<\/li>\n\n\n\n<li><strong>\u63d0\u793a\u4e8c\uff1a<\/strong> \u8be2\u95ee <code>passphrase<\/code>\uff08\u5bc6\u7801\u77ed\u8bed\uff09\uff0c\u5982\u679c\u60f3\u5f7b\u5e95\u514d\u5bc6\uff0c\u76f4\u63a5<strong>\u8fde\u6309\u4e24\u6b21\u56de\u8f66<\/strong>\uff0c\u4e0d\u8bbe\u5bc6\u7801\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">3. \u5c06\u516c\u94a5\u6dfb\u52a0\u5230 Git \u5e73\u53f0<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f60\u9700\u8981\u628a\u201c\u94a5\u5319\u201d\u4ea4\u7ed9 GitHub \u6216 Gitee\uff0c\u5b83\u4eec\u624d\u80fd\u8ba4\u51fa\u4f60\u7684\u7535\u8111\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u590d\u5236\u516c\u94a5\u5185\u5bb9\uff1a<\/strong>Bash# macOS\/Linux<br>cat ~\/.ssh\/id_ed25519.pub<br>\u200b<br># Windows (PowerShell)<br>type $HOME\\.ssh\\id_ed25519.pub<\/li>\n\n\n\n<li><strong>\u7c98\u8d34\u5230\u5e73\u53f0\uff1a<\/strong> \u767b\u5f55\u4f60\u7684 GitHub\uff0c\u8fdb\u5165 <strong>Settings -> SSH and GPG keys -> New SSH key<\/strong>\u3002\u628a\u521a\u624d\u590d\u5236\u7684\u90a3\u4e00\u5927\u4e32\u4ee5 <code>ssh-ed25519<\/code> \u5f00\u5934\u7684\u5185\u5bb9\u7c98\u8fdb\u53bb\uff0c\u8d77\u4e2a\u540d\u5b57\uff08\u6bd4\u5982 &#8220;My MacBook Pro&#8221;\uff09\u4fdd\u5b58\u5373\u53ef\u3002<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">4. \u6d4b\u8bd5\u8fde\u63a5<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u56de\u5230\u7ec8\u7aef\uff0c\u9a8c\u8bc1\u4e00\u4e0b\u662f\u5426\u6210\u529f\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Bash<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ssh -T git@github.com<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u770b\u5230\u7c7b\u4f3c <code>Hi [\u4f60\u7684\u7528\u6237\u540d]! You've successfully authenticated<\/code> \u7684\u63d0\u793a\uff0c\u606d\u559c\u4f60\uff0c\u901a\u9053\u5df2\u7ecf\u6253\u901a\u4e86\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">5.\u8fdb\u9636\uff1a<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u591a\u5bc6\u94a5\u73af\u5883\u4e0b\u7684\u914d\u7f6e\u7ba1\u7406<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f53\u4f60\u5f00\u59cb\u7ba1\u7406\u591a\u4e2a\u4e0d\u540c\u5e73\u53f0\u7684\u9879\u76ee\u65f6\uff0c\u5355\u4e00\u5bc6\u94a5\u5f80\u5f80\u4e0d\u591f\u7528\u3002\u901a\u8fc7\u914d\u7f6e <code>config<\/code> \u6587\u4ef6\uff0c\u6211\u4eec\u53ef\u4ee5\u5b9e\u73b0\u591a\u5bc6\u94a5\u7684\u81ea\u52a8\u5206\u6d41\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">1. \u751f\u6210\u72ec\u7acb\u5bc6\u94a5<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f7f\u7528 <code>-f<\/code> \u53c2\u6570\u6307\u5b9a\u5b58\u653e\u8def\u5f84\uff0c\u907f\u514d\u8986\u76d6\u9ed8\u8ba4\u5bc6\u94a5\uff1a <code>ssh-keygen -t ed25519 -f ~\/.ssh\/new_project_rsa<\/code><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">2. \u8def\u7531\u914d\u7f6e (SSH Config) \u7f16\u8f91<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\"><code>~\/.ssh\/config<\/code> \u6587\u4ef6\uff0c\u4e3a\u4e0d\u540c Host \u6307\u5b9a\u4e0d\u540c\u7684 <code>IdentityFile<\/code>\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">3. \u9a8c\u8bc1\u8fde\u63a5<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f7f\u7528\u522b\u540d\u6d4b\u8bd5\u662f\u5426\u8fde\u901a\uff1a <code>ssh -T git@work.github.com<\/code><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u6ce8\u610f\u4e8b\u9879\uff1a\u8f6c\u6362\u73b0\u6709\u7684\u9879\u76ee<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u4f60\u4e4b\u524d\u7684\u9879\u76ee\u662f\u7528 HTTPS \u65b9\u5f0f\u514b\u9686\u7684\uff08\u5730\u5740\u4ee5 <code>https:\/\/<\/code> \u5f00\u5934\uff09\uff0c\u4f60\u9700\u8981\u628a\u8fdc\u7a0b\u5730\u5740\u5207\u5230 SSH \u534f\u8bae\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Bash<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># \u4fee\u6539\u8fdc\u7a0b\u4ed3\u5e93\u5730\u5740<br>git remote set-url origin git@github.com:\u7528\u6237\u540d\/\u4ed3\u5e93\u540d.git<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u4e00\u70b9\u4e2a\u4eba\u5efa\u8bae\uff1a<\/strong> Ed25519 \u662f\u76ee\u524d\u6700\u63a8\u8350\u7684\u52a0\u5bc6\u7b97\u6cd5\uff0c\u6bd4\u4f20\u7edf\u7684 RSA \u66f4\u5feb\u4e14\u66f4\u5b89\u5168\u3002\u5982\u679c\u4f60\u5728\u516c\u53f8\u5185\u90e8\u670d\u52a1\u5668\uff08\u5982\u65e7\u7248 GitLab\uff09\u914d\u7f6e\u65f6\u53d1\u73b0\u62a5\u9519\uff0c\u53ef\u80fd\u9700\u8981\u6362\u56de <code>ssh-keygen -t rsa -b 4096<\/code> \u6765\u751f\u6210\u5bc6\u94a5\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u65e2\u7136\u804a\u5230\u8fd9\u513f\u4e86\uff0c\u90a3\u5fc5\u987b\u5b89\u6392\u4e0a\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5bf9\u4e8e\u54b1\u4eec\u8fd9\u79cd\u6bcf\u5929\u90fd\u8981\u63d0\u4ea4\u65e0\u6570\u6b21\u4ee3\u7801\u7684\u4eba\u6765\u8bf4\uff0c\u54ea\u6015\u53ea\u662f\u91cd\u590d\u6572 <code>add<\/code>\u3001<code>commit<\/code>\u3001<code>push<\/code> \u8fd9\u4e09\u884c\uff0c\u4e45\u4e86\u4e5f\u4f1a\u89c9\u5f97\u7410\u788e\u3002\u5199\u4e2a\u7b80\u5355\u7684\u81ea\u52a8\u5316\u811a\u672c\uff0c\u786e\u5b9e\u80fd\u7701\u4e0b\u4e0d\u5c11\u65f6\u95f4\u53bb\u559d\u676f\u5496\u5561\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4ee5\u4e0b\u6211\u4e3a\u4f60\u51c6\u5907\u4e86\u4e24\u4e2a\u7248\u672c\u7684\u811a\u672c\uff0c\u4f60\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u64cd\u4f5c\u7cfb\u7edf\u9009\u4e00\u4e2a\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u61d2\u4eba\u5fc5\u5907\uff1aGit \u4e00\u952e\u63d0\u4ea4\u811a\u672c<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Windows \u7528\u6237\uff08<code>.bat<\/code> \u6279\u5904\u7406\u6587\u4ef6\uff09<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u4f60\u7684\u9879\u76ee\u6839\u76ee\u5f55\u4e0b\uff0c\u65b0\u5efa\u4e00\u4e2a\u6587\u4ef6\u53eb <code>git_push.bat<\/code>\uff0c\u628a\u4e0b\u9762\u4ee3\u7801\u62f7\u8fdb\u53bb\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4ee3\u7801\u6bb5<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">@echo off<br>:: 1. \u6dfb\u52a0\u6240\u6709\u6539\u52a8<br>git add .<br><br>:: 2. \u8ba9\u7528\u6237\u8f93\u5165\u63d0\u4ea4\u4fe1\u606f\uff08\u9ed8\u8ba4\u4e3a \"update\"\uff09<br>set \/p msg=\"\u8bf7\u8f93\u5165 Commit \u4fe1\u606f (\u76f4\u63a5\u56de\u8f66\u9ed8\u8ba4\u4e3a update): \"<br>if \"%msg%\"==\"\" set msg=\"update\"<br><br>:: 3. \u6267\u884c\u63d0\u4ea4\u548c\u63a8\u9001<br>git commit -m \"%msg%\"<br>git push<br><br>echo.<br>echo === \u4efb\u52a1\u5b8c\u6210\uff01\u4ee3\u7801\u5df2\u5b89\u5168\u4e0a\u4e91 ===<br>pause<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u7528\u6cd5\uff1a<\/strong> \u4ee5\u540e\u6539\u5b8c\u4ee3\u7801\uff0c\u76f4\u63a5\u53cc\u51fb\u8fd0\u884c\u8fd9\u4e2a\u6587\u4ef6\uff0c\u8f93\u5165\u4e2a\u5907\u6ce8\uff08\u6216\u8005\u76f4\u63a5\u56de\u8f66\uff09\u5c31\u5b8c\u4e8b\u4e86\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">macOS \/ Linux \u7528\u6237\uff08Shell \u811a\u672c\uff09<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u6839\u76ee\u5f55\u4e0b\u65b0\u5efa <code>lazy_push.sh<\/code>\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Bash<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#!\/bin\/bash<br><br># 1. \u68c0\u67e5\u662f\u5426\u6709\u6539\u52a8<br>if [ -z \"$(git status --porcelain)\" ]; then <br>    echo \"\u6ca1\u6709\u68c0\u6d4b\u5230\u4efb\u4f55\u6539\u52a8\uff0c\u65e0\u9700\u63d0\u4ea4\u3002\"<br>    exit 0<br>fi<br><br># 2. \u6dfb\u52a0\u5e76\u63d0\u793a\u8f93\u5165<br>git add .<br>read -p \"\u8bf7\u8f93\u5165 Commit \u4fe1\u606f (\u9ed8\u8ba4\u4e3a update): \" msg<br>msg=${msg:-\"update\"}<br><br># 3. \u63d0\u4ea4\u5e76\u63a8\u9001<br>git commit -m \"$msg\"<br>git push<br><br>echo \"\ud83d\ude80 \u63a8\u9001\u6210\u529f\uff01\"<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u7528\u6cd5\uff1a<\/strong> 1. \u7ec8\u7aef\u6267\u884c <code>chmod +x lazy_push.sh<\/code> \u7ed9\u5b83\u8fd0\u884c\u6743\u9650\u3002 2. \u4ee5\u540e\u60f3\u63a8\u4ee3\u7801\uff0c\u7ec8\u7aef\u8f93\u5165 <code>.\/lazy_push.sh<\/code> \u5373\u53ef\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u8fdb\u9636\u7248\uff1a\u5e26\u201c\u5b89\u5168\u62a4\u680f\u201d\u7684 Git \u81ea\u52a8\u5316\u811a\u672c<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u4e2a\u811a\u672c\uff08\u4ee5 Shell \u4e3a\u4f8b\uff0c\u9002\u7528\u4e8e macOS\/Linux\/WSL\uff09\u589e\u52a0\u4e86\u4e00\u5c42\u9632\u5446\u673a\u5236\uff0c\u786e\u4fdd\u4f60\u5728\u63a8\u9001\u524d\u662f\u6e05\u9192\u4e14\u5b89\u5168\u7684\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u811a\u672c\u4ee3\u7801\uff1a<code>super_push.sh<\/code><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Bash<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#!\/bin\/bash<br><br># 1. \u81ea\u52a8\u83b7\u53d6\u5f53\u524d\u5206\u652f\u540d<br>current_branch=$(git symbolic-ref --short HEAD)<br><br># 2. \u72b6\u6001\u68c0\u67e5\uff1a\u5982\u679c\u6ca1\u6709\u6539\u52a8\u5219\u9000\u51fa<br>if [ -z \"$(git status --porcelain)\" ]; then<br>    echo \"\u2728 \u5e72\u51c0\u5f97\u50cf\u6d17\u8fc7\u4e00\u6837\uff0c\u6ca1\u6709\u4efb\u4f55\u6539\u52a8\u9700\u8981\u63d0\u4ea4\u3002\"<br>    exit 0<br>fi<br><br># 3. \u5206\u652f\u5b89\u5168\u63d0\u9192<br>echo \"\u5f53\u524d\u5206\u652f: [$current_branch]\"<br>if [ \"$current_branch\" == \"main\" ] || [ \"$current_branch\" == \"master\" ]; then<br>    read -p \"\u26a0\ufe0f  \u6ce8\u610f\uff1a\u4f60\u6b63\u5728\u4e3b\u5206\u652f\u4e0a\u64cd\u4f5c\uff0c\u786e\u5b9a\u8981\u7ee7\u7eed\u5417\uff1f(y\/n): \" confirm<br>    if [ \"$confirm\" != \"y\" ]; then<br>        echo \"\u64cd\u4f5c\u5df2\u53d6\u6d88\uff0c\u5efa\u8bae\u53bb\u5f00\u53d1\u5206\u652f\u63d0\u4ea4\u3002\"<br>        exit 1<br>    fi<br>fi<br><br># 4. \u9884\u5148\u62c9\u53d6\uff0c\u9632\u6b62\u51b2\u7a81<br>echo \"\u6b63\u5728\u540c\u6b65\u8fdc\u7a0b\u4ee3\u7801...\"<br>git pull origin $current_branch --rebase<br><br>if [ $? -ne 0 ]; then<br>    echo \"\u274c \u62c9\u53d6\u5931\u8d25\uff0c\u53ef\u80fd\u5b58\u5728\u51b2\u7a81\uff0c\u8bf7\u624b\u52a8\u5904\u7406\u540e\u518d\u8bd5\u3002\"<br>    exit 1<br>fi<br><br># 5. \u6267\u884c\u63d0\u4ea4<br>git add .<br>read -p \"\u8bf7\u8f93\u5165 Commit \u4fe1\u606f: \" msg<br>if [ -z \"$msg\" ]; then<br>    msg=\"chore: \u5feb\u901f\u63d0\u4ea4\u4e8e $(date '+%Y-%m-%d %H:%M')\"<br>fi<br><br>git commit -m \"$msg\"<br><br># 6. \u63a8\u9001\u5e76\u53cd\u9988\u7ed3\u679c<br>if git push origin $current_branch; then<br>    echo \"\ud83d\ude80 [\u6210\u529f] \u4ee3\u7801\u5df2\u5b89\u5168\u9001\u8fbe $current_branch \u5206\u652f\uff01\"<br>else<br>    echo \"\u274c [\u9519\u8bef] \u63a8\u9001\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u7f51\u7edc\u6216\u6743\u9650\u3002\"<br>fi<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h4 class=\"wp-block-heading\">\u8fd9\u4efd\u811a\u672c\u5f3a\u5728\u54ea\uff1f<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u667a\u80fd\u611f\u5e94\uff1a<\/strong> \u81ea\u52a8\u8bc6\u522b\u4f60\u5f53\u524d\u5728\u54ea\u4e2a\u5206\u652f\uff0c\u4e0d\u7528\u6bcf\u6b21\u624b\u52a8\u6307\u5b9a\u3002<\/li>\n\n\n\n<li><strong>\u5206\u652f\u9884\u8b66\uff1a<\/strong> \u5f53\u4f60\u5728 <code>main<\/code> \u6216 <code>master<\/code> \u8fd9\u79cd\u751f\u4ea7\u73af\u5883\u5206\u652f\u64cd\u4f5c\u65f6\uff0c\u5b83\u4f1a\u8df3\u51fa\u6765\u62e6\u4f60\u4e00\u4e0b\u3002\u522b\u5c0f\u770b\u8fd9\u4e00\u4e0b\uff0c\u5f88\u591a\u201c\u751f\u4ea7\u4e8b\u6545\u201d\u5c31\u662f\u56e0\u4e3a\u5c11\u770b\u4e86\u4e00\u773c\u5206\u652f\u540d\u3002<\/li>\n\n\n\n<li><strong>\u5148\u62c9\u540e\u63a8\uff1a<\/strong> \u5f3a\u5236\u6267\u884c <code>git pull --rebase<\/code>\u3002\u8fd9\u662f\u4e2a\u597d\u4e60\u60ef\uff0c\u5b83\u80fd\u8ba9\u4f60\u7684\u63d0\u4ea4\u5386\u53f2\u4fdd\u6301\u4e00\u6761\u76f4\u7ebf\uff0c\u800c\u4e0d\u662f\u5230\u5904\u90fd\u662f\u4e11\u964b\u7684 &#8220;Merge branch&#8230;&#8221; \u8282\u70b9\u3002<\/li>\n\n\n\n<li><strong>\u8bed\u4e49\u5316\u4fe1\u606f\uff1a<\/strong> \u5982\u679c\u4f60\u76f4\u63a5\u56de\u8f66\u6ca1\u5199\u5907\u6ce8\uff0c\u5b83\u4f1a\u81ea\u52a8\u5e2e\u4f60\u8865\u4e00\u4e2a\u5e26\u65f6\u95f4\u6233\u7684\u5907\u6ce8\uff0c\u4e0d\u81f3\u4e8e\u8ba9 Git \u5386\u53f2\u91cc\u51fa\u73b0\u7a7a\u4fe1\u606f\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h4 class=\"wp-block-heading\">\u5982\u4f55\u5728 Windows \u4e0b\u8fbe\u5230\u540c\u6837\u6548\u679c\uff1f<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u4f60\u662f Windows \u7528\u6237\uff0c\u4e0d\u60f3\u6298\u817e\u590d\u6742\u7684 <code>.bat<\/code> \u903b\u8f91\uff0c\u6211\u5176\u5b9e\u6700\u63a8\u8350\u4f60\u7ed9 Git \u8bbe\u7f6e <strong>Alias\uff08\u522b\u540d\uff09<\/strong>\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u7ec8\u7aef\u8f93\u5165\u8fd9\u4e2a\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Bash<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">git config --global alias.lazy \"!f() { git add . &amp;&amp; git commit -m \\\"${1:-update}\\\" &amp;&amp; git push; }; f\"<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8bbe\u7f6e\u597d\u540e\uff0c\u4f60\u4ee5\u540e\u53ea\u9700\u8981\u5728\u4efb\u4f55\u9879\u76ee\u91cc\u8f93\u5165\uff1a <code>git lazy \"\u5b8c\u6210\u4e86\u767b\u5f55\u903b\u8f91\"<\/code> \u5b83\u5c31\u4f1a\u81ea\u52a8\u5e2e\u4f60\u5b8c\u6210 <code>add<\/code>\u3001<code>commit<\/code>\u3001<code>push<\/code> \u4e09\u8fde\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udea8 \u907f\u5751\uff1a\u811a\u672c\u867d\u597d\uff0c\u522b\u5fd8\u4e86\u8fd9\u51e0\u70b9<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u867d\u7136\u4e00\u952e\u811a\u672c\u5f88\u723d\uff0c\u4f46\u4f5c\u4e3a\u201c\u8fc7\u6765\u4eba\u201d\uff0c\u6709\u4e24\u70b9\u5f97\u63d0\u9192\u4f60\uff0c\u4e0d\u7136\u5bb9\u6613\u7ffb\u8f66\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u522b\u6f0f\u4e86 <code>.gitignore<\/code>\uff1a<\/strong> \u811a\u672c\u4f1a\u6267\u884c <code>git add .<\/code>\uff0c\u8fd9\u610f\u5473\u7740\u5b83\u4f1a\u628a\u76ee\u5f55\u4e0b<strong>\u6240\u6709<\/strong>\u6ca1\u88ab\u5ffd\u7565\u7684\u6587\u4ef6\u5168\u6293\u8fdb\u53bb\u3002\u5982\u679c\u4f60\u7684 <code>.gitignore<\/code> \u6ca1\u5199\u597d\uff0c\u53ef\u80fd\u4f1a\u4e0d\u5c0f\u5fc3\u628a\u5de8\u5927\u7684\u4e34\u65f6\u6587\u4ef6\u6216\u8005\u5305\u542b\u5bc6\u7801\u7684\u914d\u7f6e\u6587\u4ef6\u4f20\u4e0a\u53bb\u3002<\/li>\n\n\n\n<li><strong>\u51b2\u7a81\u5904\u7406\uff1a<\/strong> \u8fd9\u79cd\u811a\u672c\u9002\u5408\u53ea\u6709\u4f60\u4e00\u4e2a\u4eba\u5f00\u53d1\u7684\u4e2a\u4eba\u9879\u76ee\u3002\u5982\u679c\u662f\u591a\u4eba\u534f\u4f5c\uff0c\u5efa\u8bae\u5728\u811a\u672c\u5f00\u5934\u52a0\u4e00\u884c <code>git pull<\/code>\uff0c\u5148\u62c9\u53d6\u522b\u4eba\u7684\u4ee3\u7801\uff0c\u9632\u6b62\u56e0\u4e3a\u4ee3\u7801\u51b2\u7a81\u5bfc\u81f4 <code>push<\/code> \u5931\u8d25\u3002<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u7ed3\u8bed<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u6298\u817e\u8fd9\u4e9b\u5c0f\u5de5\u5177\u7684\u610f\u4e49\uff0c\u4e0d\u5728\u4e8e\u7701\u4e0b\u90a3\u51e0\u79d2\u949f\uff0c\u800c\u5728\u4e8e\u628a\u8fd9\u79cd<strong>\u91cd\u590d\u6027\u7684\u673a\u68b0\u52b3\u52a8<\/strong>\u4ea4\u7ed9\u8ba1\u7b97\u673a\uff0c\u628a\u54b1\u4eec\u7684\u6ce8\u610f\u529b\u7559\u7ed9\u66f4\u6709\u4ef7\u503c\u7684\u903b\u8f91\u548c\u521b\u610f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f5c\u4e3a\u5f00\u53d1\u8005\uff0c\u6211\u4eec\u6700\u5b9d\u8d35\u7684\u8d44\u4ea7\u5c31\u662f\u4ee3\u7801\u3002\u5f88\u591a\u4eba\u4e60\u60ef\u4e8e\u672c\u5730\u5f00\u53d1\uff0c\u4f46\u5982\u679c\u7f3a\u4e4f\u8fdc\u7a0b\u5907\u4efd\uff0c\u4e00\u65e6\u906d\u9047\u786c\u4ef6\u6545\u969c\u6216\u8bef\u64cd\u4f5c\uff0c\u635f\u5931 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-140","post","type-post","status-publish","format-standard","hentry","category-8"],"_links":{"self":[{"href":"https:\/\/muse.lzink.icu\/index.php?rest_route=\/wp\/v2\/posts\/140","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/muse.lzink.icu\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/muse.lzink.icu\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/muse.lzink.icu\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/muse.lzink.icu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=140"}],"version-history":[{"count":1,"href":"https:\/\/muse.lzink.icu\/index.php?rest_route=\/wp\/v2\/posts\/140\/revisions"}],"predecessor-version":[{"id":141,"href":"https:\/\/muse.lzink.icu\/index.php?rest_route=\/wp\/v2\/posts\/140\/revisions\/141"}],"wp:attachment":[{"href":"https:\/\/muse.lzink.icu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=140"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/muse.lzink.icu\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=140"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/muse.lzink.icu\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=140"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}