{"id":87165,"date":"2026-07-29T23:24:43","date_gmt":"2026-07-29T15:24:43","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/87165.html"},"modified":"2026-07-29T23:24:43","modified_gmt":"2026-07-29T15:24:43","slug":"04-%e4%b8%80%e6%ac%a1-git-%e6%8f%90%e4%ba%a4%e5%89%8d%e5%90%8e%ef%bc%8c%e5%ba%94%e8%af%a5%e6%a3%80%e6%9f%a5%e4%bb%80%e4%b9%88%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/87165.html","title":{"rendered":"04.\u4e00\u6b21 Git \u63d0\u4ea4\u524d\u540e\uff0c\u5e94\u8be5\u68c0\u67e5\u4ec0\u4e48\uff1f"},"content":{"rendered":"<p>\u4ece\u666e\u901a\u76ee\u5f55\u5b8c\u6210\u7b2c\u4e00\u6b21\u672c\u5730\u63d0\u4ea4\u5e76\u4e0d\u96be&#xff0c;\u4f46\u771f\u5b9e\u5f00\u53d1\u5f88\u5c11\u4e00\u76f4\u4fdd\u6301\u201c\u53ea\u4fee\u6539\u4e00\u4e2a\u6587\u4ef6&#xff0c;\u7136\u540e\u7acb\u5373\u63d0\u4ea4\u201d\u7684\u7406\u60f3\u72b6\u6001\u3002<\/p>\n<p>\u5199\u4e00\u4e2a\u529f\u80fd\u65f6\u53ef\u80fd\u540c\u65f6\u51fa\u73b0&#xff1a;<\/p>\n<ul>\n<li>\u5f53\u524d\u771f\u6b63\u8981\u63d0\u4ea4\u7684\u4ee3\u7801&#xff1b;<\/li>\n<li>\u987a\u624b\u4fee\u6539\u4f46\u5e94\u5355\u72ec\u63d0\u4ea4\u7684\u6587\u6863&#xff1b;<\/li>\n<li>\u8fd0\u884c\u7a0b\u5e8f\u4ea7\u751f\u7684\u65e5\u5fd7&#xff1b;<\/li>\n<li>\u53ea\u5c5e\u4e8e\u672c\u673a\u7684\u73af\u5883\u914d\u7f6e\u3002<\/li>\n<\/ul>\n<p>\u8fd9\u65f6&#xff0c;add \u548c commit \u672c\u8eab\u5e76\u4e0d\u96be&#xff0c;\u771f\u6b63\u9700\u8981\u5224\u65ad\u7684\u662f&#xff1a;<\/p>\n<p>\u54ea\u4e9b\u53d8\u5316\u5c5e\u4e8e\u8fd9\u6b21\u63d0\u4ea4&#xff0c;\u54ea\u4e9b\u5e94\u8be5\u7559\u5728\u5916\u9762&#xff1f;<\/p>\n<h3>\u56db\u4e2a\u68c0\u67e5\u7a97\u53e3<\/h3>\n<p>\u4e00\u6b21\u63d0\u4ea4\u524d\u540e&#xff0c;\u53ef\u4ee5\u4ece\u56db\u4e2a\u89d2\u5ea6\u89c2\u5bdf\u4ed3\u5e93&#xff1a;<\/p>\n<table>\n<tr>\u60f3\u77e5\u9053\u4ec0\u4e48\u547d\u4ee4<\/tr>\n<tbody>\n<tr>\n<td>\u54ea\u4e9b\u8def\u5f84\u53d1\u751f\u4e86\u53d8\u5316&#xff0c;\u5206\u522b\u4f4d\u4e8e\u54ea\u4e00\u5c42<\/td>\n<td>git status &#8211;short<\/td>\n<\/tr>\n<tr>\n<td>\u5de5\u4f5c\u533a\u76f8\u5bf9\u6682\u5b58\u533a\u8fd8\u6709\u54ea\u4e9b\u5177\u4f53\u53d8\u5316<\/td>\n<td>git diff<\/td>\n<\/tr>\n<tr>\n<td>\u6682\u5b58\u533a\u76f8\u5bf9\u5f53\u524d\u63d0\u4ea4\u51c6\u5907\u8bb0\u5f55\u4ec0\u4e48<\/td>\n<td>git diff &#8211;cached&#xff0c;\u4e5f\u53ef\u4ee5\u4f7f\u7528 git diff &#8211;staged<\/td>\n<\/tr>\n<tr>\n<td>\u63d0\u4ea4\u5b8c\u6210\u540e\u5f62\u6210\u4e86\u4ec0\u4e48\u5386\u53f2<\/td>\n<td>git log &#8211;oneline\u3001git show<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>status \u5148\u544a\u8bc9\u6211\u4eec\u201c\u54ea\u91cc\u6709\u53d8\u5316\u201d&#xff0c;diff \u518d\u8bf4\u660e\u201c\u5185\u5bb9\u600e\u6837\u53d8\u5316\u201d&#xff0c;log \u548c show \u7528\u4e8e\u63d0\u4ea4\u540e\u6838\u5bf9\u5df2\u7ecf\u5f62\u6210\u7684\u8bb0\u5f55\u3002<\/p>\n<h3>\u51c6\u5907\u72ec\u7acb\u5b9e\u9a8c\u4ed3\u5e93<\/h3>\n<p>\u4e0b\u9762\u7684\u521d\u59cb\u5316\u548c\u7b2c\u4e00\u6b21\u63d0\u4ea4\u53ea\u7528\u4e8e\u5efa\u7acb\u53ef\u590d\u73b0\u7684\u524d\u7f6e\u72b6\u6001\u3002\u5982\u679c\u672c\u5730\u5df2\u6709\u540c\u540d\u76ee\u5f55&#xff0c;\u8bf7\u6362\u4e00\u4e2a\u65b0\u540d\u5b57\u3002<\/p>\n<p>mkdir commit-check-lab<br \/>\ncd commit-check-lab<br \/>\ngit init<br \/>\ngit config user.name &#034;Git Blog Lab&#034;<br \/>\ngit config user.email &#034;git-blog&#064;example.invalid&#034;<\/p>\n<p>printf &#034;login validation\\\\n&#034; &gt; app.txt<br \/>\nprintf &#034;old documentation\\\\n&#034; &gt; README.md<br \/>\ngit add app.txt README.md<br \/>\ngit commit -m &#034;chore: initialize commit check lab&#034; <\/p>\n<p>\u73b0\u5728\u4ed3\u5e93\u6709\u4e00\u4e2a\u521d\u59cb\u63d0\u4ea4&#xff0c;\u5de5\u4f5c\u533a\u662f\u5e72\u51c0\u7684\u3002<\/p>\n<h3>\u5148\u5904\u7406\u4e0d\u5e94\u8fdb\u5165\u4ed3\u5e93\u7684\u6587\u4ef6<\/h3>\n<p>\u8fd0\u884c\u7a0b\u5e8f\u65f6\u7ecf\u5e38\u4ea7\u751f\u65e5\u5fd7&#xff0c;\u672c\u5730\u5f00\u53d1\u4e5f\u53ef\u80fd\u9700\u8981\u53ea\u5c5e\u4e8e\u4e2a\u4eba\u73af\u5883\u7684\u914d\u7f6e\u3002\u5148\u5236\u9020\u4e24\u4e2a\u672a\u8ddf\u8e2a\u6587\u4ef6&#xff1a;<\/p>\n<p>printf &#034;debug output\\\\n&#034; &gt; debug.log<br \/>\nprintf &#034;local development configuration\\\\n&#034; &gt; .env<br \/>\ngit status &#8211;short <\/p>\n<p>\u8f93\u51fa\u4f1a\u5305\u542b&#xff1a;<\/p>\n<p>?? .env<br \/>\n?? debug.log <\/p>\n<p>\u5b83\u4eec\u90fd\u662f\u5de5\u4f5c\u533a\u4e2d\u7684\u672a\u8ddf\u8e2a\u6587\u4ef6\u3002\u5982\u679c\u76f4\u63a5\u6267\u884c git add .&#xff0c;\u5c31\u53ef\u80fd\u628a\u5b83\u4eec\u4e00\u8d77\u653e\u5165\u6682\u5b58\u533a\u3002<\/p>\n<p>\u5728\u4ed3\u5e93\u6839\u76ee\u5f55\u521b\u5efa .gitignore&#xff1a;<\/p>\n<p>printf &#034;*.log\\\\n.env\\\\n&#034; &gt; .gitignore<br \/>\ngit status &#8211;short <\/p>\n<p>\u73b0\u5728\u8f93\u51fa\u4e2d\u4e0d\u518d\u663e\u793a debug.log \u548c .env&#xff0c;\u53ea\u4f1a\u51fa\u73b0\u65b0\u7684 .gitignore&#xff1a;<\/p>\n<p>?? .gitignore <\/p>\n<p>\u5ffd\u7565\u89c4\u5219\u672c\u8eab\u662f\u9879\u76ee\u7ea6\u5b9a&#xff0c;\u5e94\u8be5\u8fdb\u5165\u7248\u672c\u5386\u53f2&#xff1a;<\/p>\n<p>git add .gitignore<br \/>\ngit commit -m &#034;chore: ignore logs and local environment files&#034; <\/p>\n<h4>.gitignore \u7684\u4e24\u4e2a\u8fb9\u754c<\/h4>\n<p>\u7b2c\u4e00&#xff0c;.gitignore \u4e3b\u8981\u5f71\u54cd\u5c1a\u672a\u88ab\u8ddf\u8e2a\u7684\u8def\u5f84\u3002\u6587\u4ef6\u5982\u679c\u5df2\u7ecf\u8fdb\u5165\u63d0\u4ea4&#xff0c;\u540e\u6765\u8865\u5199\u5ffd\u7565\u89c4\u5219\u4e0d\u4f1a\u81ea\u52a8\u505c\u6b62\u8ddf\u8e2a\u3002<\/p>\n<p>\u5982\u679c\u8bef\u8ddf\u8e2a\u7684\u662f\u666e\u901a\u65e5\u5fd7\u6216\u672c\u5730\u751f\u6210\u6587\u4ef6&#xff0c;\u53ef\u4ee5\u5728\u5199\u597d\u5ffd\u7565\u89c4\u5219\u540e\u505c\u6b62\u8ddf\u8e2a&#xff1a;<\/p>\n<p>git rm &#8211;cached &lt;\u6587\u4ef6&gt;<br \/>\ngit add .gitignore<br \/>\ngit commit -m &#034;chore: stop tracking generated file&#034; <\/p>\n<p>&#8211;cached \u4f1a\u628a\u5220\u9664\u8bb0\u5f55\u653e\u5165\u6682\u5b58\u533a&#xff0c;\u4f46\u4fdd\u7559\u672c\u5730\u5de5\u4f5c\u533a\u6587\u4ef6\u3002\u76ee\u5f55\u9700\u8981\u914d\u5408 -r \u4f7f\u7528\u3002\u6267\u884c\u540e\u5e94\u5148\u7528 git status \u786e\u8ba4\u6682\u5b58\u5185\u5bb9&#xff0c;\u518d\u63d0\u4ea4\u8fd9\u6b21\u89c4\u5219\u53d8\u66f4\u3002<\/p>\n<p>\u7b2c\u4e8c&#xff0c;\u5ffd\u7565\u89c4\u5219\u4e0d\u662f\u51ed\u636e\u6cc4\u9732\u540e\u7684\u8865\u6551\u5de5\u5177\u3002\u5bc6\u94a5\u3001Token \u6216\u5bc6\u7801\u4e00\u65e6\u8fdb\u5165\u5386\u53f2&#xff0c;\u5e94\u7acb\u5373\u8f6e\u6362\u6216\u4f5c\u5e9f&#xff0c;\u518d\u6839\u636e\u56e2\u961f\u6d41\u7a0b\u5904\u7406\u4ed3\u5e93\u5386\u53f2\u3002\u4ec5\u4ec5\u5220\u9664\u6587\u4ef6\u6216\u8865\u5199 .gitignore&#xff0c;\u4e0d\u80fd\u8ba9\u5df2\u7ecf\u6cc4\u9732\u7684\u503c\u5931\u6548\u3002<\/p>\n<h3>\u5236\u9020\u4e00\u4e2a\u6df7\u5408\u4fee\u6539\u73b0\u573a<\/h3>\n<p>printf &#034;check empty username\\\\n&#034; &gt;&gt; app.txt<br \/>\nprintf &#034;new usage example\\\\n&#034; &gt;&gt; README.md<br \/>\nprintf &#034;another debug line\\\\n&#034; &gt;&gt; debug.log<br \/>\ngit status &#8211;short <\/p>\n<p>\u8f93\u51fa&#xff1a;<\/p>\n<p> M README.md<br \/>\n M app.txt <\/p>\n<p>debug.log \u4ecd\u5b58\u5728\u4e8e\u672c\u5730&#xff0c;\u4f46\u56e0\u4e3a\u5339\u914d .gitignore&#xff0c;\u4e0d\u4f1a\u51fa\u73b0\u5728\u666e\u901a\u72b6\u6001\u7ed3\u679c\u4e2d\u3002<\/p>\n<p>git status &#8211;short \u5728\u6587\u4ef6\u540d\u524d\u4f7f\u7528\u4e24\u4e2a\u4f4d\u7f6e\u663e\u793a\u72b6\u6001&#xff0c;\u53ef\u4ee5\u5199\u6210&#xff1a;<\/p>\n<p>XY \u6587\u4ef6\u540d <\/p>\n<ul>\n<li>\u7b2c\u4e00\u4e2a\u4f4d\u7f6e X&#xff1a;\u5df2\u7ecf\u8fdb\u5165\u6682\u5b58\u533a\u7684\u53d8\u5316&#xff1b;<\/li>\n<li>\u7b2c\u4e8c\u4e2a\u4f4d\u7f6e Y&#xff1a;\u4ecd\u5728\u5de5\u4f5c\u533a\u3001\u5c1a\u672a\u6682\u5b58\u7684\u53d8\u5316\u3002<\/li>\n<\/ul>\n<p>\u5f53\u524d\u4e24\u4e2a\u6587\u4ef6\u663e\u793a\u4e3a  M&#xff1a;\u7b2c\u4e00\u4e2a\u4f4d\u7f6e\u4e3a\u7a7a&#xff0c;\u7b2c\u4e8c\u4e2a\u4f4d\u7f6e\u662f M&#xff0c;\u8bf4\u660e\u6587\u4ef6\u53ea\u5728\u5de5\u4f5c\u533a\u53d1\u751f\u4e86\u4fee\u6539&#xff0c;\u8fd8\u6ca1\u6709\u8fdb\u5165\u6682\u5b58\u533a\u3002<\/p>\n<h3>diff&#xff1a;\u68c0\u67e5\u5177\u4f53\u6539\u4e86\u4ec0\u4e48<\/h3>\n<p>\u5148\u68c0\u67e5\u51c6\u5907\u4f5c\u4e3a\u5f53\u524d\u529f\u80fd\u63d0\u4ea4\u7684\u6587\u4ef6&#xff1a;<\/p>\n<p>git diff &#8212; app.txt <\/p>\n<p>\u8fd9\u91cc\u4f1a\u770b\u5230\u65b0\u589e\u7684 check empty username\u3002<\/p>\n<p>\u518d\u68c0\u67e5\u6587\u6863&#xff1a;<\/p>\n<p>git diff &#8212; README.md <\/p>\n<p>\u8fd9\u91cc\u4f1a\u770b\u5230\u53e6\u4e00\u4e2a\u72ec\u7acb\u610f\u56fe&#xff1a;\u8865\u5145\u4f7f\u7528\u793a\u4f8b\u3002<\/p>\n<p>\u666e\u901a git diff \u6bd4\u8f83\u5de5\u4f5c\u533a\u548c\u6682\u5b58\u533a&#xff0c;\u4e0d\u4f1a\u5c55\u793a\u666e\u901a\u672a\u8ddf\u8e2a\u6587\u4ef6\u7684\u5185\u5bb9\u3002\u56e0\u6b64&#xff0c;\u68c0\u67e5\u73b0\u573a\u65f6\u4e0d\u80fd\u53ea\u770b diff&#xff0c;\u8fd8\u8981\u5148\u770b status&#xff1b;\u5426\u5219\u53ef\u80fd\u6f0f\u6389\u5c1a\u672a\u8ddf\u8e2a\u3001\u4e5f\u672a\u88ab\u5ffd\u7565\u7684\u6587\u4ef6\u3002<\/p>\n<h3>\u53ea\u9009\u62e9\u5c5e\u4e8e\u672c\u6b21\u63d0\u4ea4\u7684\u53d8\u5316<\/h3>\n<p>\u8fd9\u6b21\u5148\u63d0\u4ea4\u767b\u5f55\u6821\u9a8c&#xff0c;\u4e0d\u628a\u6587\u6863\u4fee\u6539\u6df7\u8fdb\u53bb&#xff1a;<\/p>\n<p>git add app.txt<br \/>\ngit status &#8211;short <\/p>\n<p>\u8f93\u51fa&#xff1a;<\/p>\n<p> M README.md<br \/>\nM  app.txt <\/p>\n<p>app.txt \u7684 M \u8fdb\u5165\u5de6\u5217&#xff0c;\u8bf4\u660e\u5b83\u5df2\u7ecf\u88ab\u6682\u5b58&#xff1b;README.md \u7684\u4fee\u6539\u4ecd\u5728\u5de5\u4f5c\u533a\u3002<\/p>\n<p>\u63d0\u4ea4\u524d\u68c0\u67e5\u6682\u5b58\u533a\u4e2d\u7684\u5b9e\u9645\u5185\u5bb9&#xff1a;<\/p>\n<p>git diff &#8211;cached &#8212; app.txt <\/p>\n<p>\u8fd9\u91cc\u53ea\u5e94\u8be5\u51fa\u73b0\u4e0e\u767b\u5f55\u6821\u9a8c\u6709\u5173\u7684\u53d8\u5316\u3002\u786e\u8ba4\u8fb9\u754c\u6b63\u786e\u540e\u518d\u63d0\u4ea4&#xff1a;<\/p>\n<p>git commit -m &#034;feat: validate empty username&#034; <\/p>\n<p>\u4e00\u6b21\u63d0\u4ea4\u53ef\u4ee5\u540c\u65f6\u5305\u542b\u4ee3\u7801\u3001\u6d4b\u8bd5\u548c\u5fc5\u8981\u6587\u6863&#xff0c;\u5173\u952e\u4e0d\u662f\u201c\u53ea\u80fd\u6539\u4e00\u4e2a\u6587\u4ef6\u201d&#xff0c;\u800c\u662f\u8fd9\u4e9b\u53d8\u5316\u80fd\u5426\u5171\u540c\u8868\u8fbe\u540c\u4e00\u4e2a\u610f\u56fe&#xff0c;\u5e76\u4e14\u53ef\u4ee5\u4e00\u8d77\u8bc4\u5ba1\u548c\u64a4\u9500\u3002<\/p>\n<h3>\u63d0\u4ea4\u540e\u4e0d\u8981\u7acb\u5373\u79bb\u5f00<\/h3>\n<p>\u63d0\u4ea4\u5b8c\u6210\u540e\u5148\u770b\u72b6\u6001&#xff1a;<\/p>\n<p>git status &#8211;short <\/p>\n<p>\u8f93\u51fa&#xff1a;<\/p>\n<p> M README.md <\/p>\n<p>\u8fd9\u8bf4\u660e\u529f\u80fd\u53d8\u5316\u5df2\u7ecf\u63d0\u4ea4&#xff0c;\u6587\u6863\u4fee\u6539\u4ecd\u7136\u5b89\u5168\u5730\u7559\u5728\u5de5\u4f5c\u533a\u3002\u63d0\u4ea4\u4e0d\u4f1a\u81ea\u52a8\u5e26\u8d70\u6ca1\u6709\u8fdb\u5165\u6682\u5b58\u533a\u7684\u53d8\u5316\u3002<\/p>\n<p>\u63a5\u7740\u67e5\u770b\u6700\u8fd1\u5386\u53f2&#xff1a;<\/p>\n<p>git log &#8211;oneline -3 <\/p>\n<p>\u5b83\u7528\u4e8e\u5feb\u901f\u786e\u8ba4\u6700\u8fd1\u63d0\u4ea4\u7684\u987a\u5e8f\u548c\u8bf4\u660e\u3002<\/p>\n<p>\u67e5\u770b\u521a\u624d\u90a3\u6b21\u63d0\u4ea4\u6d89\u53ca\u54ea\u4e9b\u6587\u4ef6&#xff1a;<\/p>\n<p>git show &#8211;stat HEAD <\/p>\n<p>\u67e5\u770b\u63d0\u4ea4\u7684\u5b8c\u6574\u5185\u5bb9&#xff1a;<\/p>\n<p>git show HEAD <\/p>\n<p>HEAD \u8868\u793a\u5f53\u524d\u68c0\u51fa\u4f4d\u7f6e\u5bf9\u5e94\u7684\u63d0\u4ea4\u3002\u5728\u901a\u5e38\u7684\u5206\u652f\u72b6\u6001\u4e0b&#xff0c;\u5b83\u901a\u8fc7\u5f53\u524d\u5206\u652f\u5b9a\u4f4d\u5230\u6700\u65b0\u63d0\u4ea4\u3002<\/p>\n<p>\u786e\u8ba4\u529f\u80fd\u63d0\u4ea4\u6ca1\u6709\u6df7\u5165 README \u540e&#xff0c;\u518d\u628a\u6587\u6863\u4f5c\u4e3a\u72ec\u7acb\u63d0\u4ea4&#xff1a;<\/p>\n<p>git add README.md<br \/>\ngit diff &#8211;cached &#8212; README.md<br \/>\ngit commit -m &#034;docs: add usage example&#034;<br \/>\ngit status <\/p>\n<p>\u6700\u540e\u7684\u72b6\u6001\u5e94\u8be5\u662f\u5e72\u51c0\u7684\u3002<\/p>\n<h3>\u540c\u4e00\u4e2a\u6587\u4ef6\u5305\u542b\u4e24\u4e2a\u610f\u56fe\u600e\u4e48\u529e<\/h3>\n<p>\u6309\u8def\u5f84\u6267\u884c git add app.txt \u4f1a\u9009\u62e9\u8fd9\u4e2a\u6587\u4ef6\u5f53\u524d\u7684\u5168\u90e8\u53d8\u5316\u3002\u4f46\u540c\u4e00\u4e2a\u6587\u4ef6\u4e5f\u53ef\u80fd\u540c\u65f6\u5305\u542b\u4e24\u4e2a\u4e0d\u540c\u610f\u56fe\u3002<\/p>\n<p>\u6b64\u65f6\u53ef\u4ee5\u4ea4\u4e92\u5f0f\u9009\u62e9\u5dee\u5f02\u5757&#xff1a;<\/p>\n<p>git add &#8211;patch app.txt <\/p>\n<p>Git \u4f1a\u628a\u53d8\u5316\u5206\u6210\u82e5\u5e72\u5757&#xff0c;\u8ba9\u6211\u4eec\u9010\u5757\u51b3\u5b9a\u662f\u5426\u6682\u5b58\u3002\u6ca1\u6709\u9009\u4e2d\u7684\u90e8\u5206\u4ecd\u7559\u5728\u5de5\u4f5c\u533a&#xff0c;\u4e0d\u4f1a\u88ab\u5220\u9664\u3002<\/p>\n<p>\u5b8c\u6210\u540e\u5206\u522b\u68c0\u67e5&#xff1a;<\/p>\n<p>git diff &#8211;cached &#8212; app.txt<br \/>\ngit diff &#8212; app.txt <\/p>\n<p>\u7b2c\u4e00\u6761\u67e5\u770b\u5df2\u7ecf\u9009\u5165\u4e0b\u6b21\u63d0\u4ea4\u7684\u53d8\u5316&#xff0c;\u7b2c\u4e8c\u6761\u67e5\u770b\u4ecd\u7559\u5728\u5de5\u4f5c\u533a\u7684\u53d8\u5316\u3002\u5982\u679c\u4e00\u4e2a\u5dee\u5f02\u5757\u5185\u90e8\u4ecd\u7136\u6df7\u7740\u4e24\u4e2a\u610f\u56fe&#xff0c;\u53ef\u4ee5\u7ee7\u7eed\u62c6\u5206\u5dee\u5f02\u5757&#xff0c;\u6216\u8005\u5148\u56de\u5230\u7f16\u8f91\u5668\u6574\u7406\u5185\u5bb9\u3002<\/p>\n<h3>\u4e3a\u4ec0\u4e48\u4e0d\u628a commit -am \u5f53\u4f5c\u9ed8\u8ba4\u52a8\u4f5c<\/h3>\n<p>git commit -am &#034;message&#034; <\/p>\n<p>\u8fd9\u4e2a\u5199\u6cd5\u4f1a\u5728\u63d0\u4ea4\u524d\u81ea\u52a8\u6682\u5b58\u6240\u6709\u5df2\u8ddf\u8e2a\u6587\u4ef6\u7684\u4fee\u6539\u548c\u5220\u9664&#xff0c;\u5e76\u63d0\u4ea4\u5b83\u4eec\u6267\u884c\u547d\u4ee4\u65f6\u7684\u5f53\u524d\u5185\u5bb9&#xff0c;\u4f46\u4e0d\u4f1a\u7eb3\u5165\u666e\u901a\u672a\u8ddf\u8e2a\u6587\u4ef6\u3002<\/p>\n<p>\u5b83\u4e5f\u4f1a\u7ed5\u8fc7\u201c\u9009\u62e9\u8def\u5f84 \u2192 \u68c0\u67e5\u6682\u5b58\u5dee\u5f02\u201d\u7684\u8fc7\u7a0b\u3002\u5982\u679c\u540c\u4e00\u4e2a\u5df2\u8ddf\u8e2a\u6587\u4ef6\u5728\u6682\u5b58\u540e\u53c8\u7ee7\u7eed\u4fee\u6539&#xff0c;-a \u4f1a\u628a\u540e\u7eed\u5de5\u4f5c\u533a\u4fee\u6539\u4e00\u8d77\u7eb3\u5165\u63d0\u4ea4&#xff0c;\u53ef\u80fd\u7834\u574f\u539f\u672c\u9009\u62e9\u597d\u7684\u8fb9\u754c\u3002<\/p>\n<p>\u53ea\u6709\u5f53\u6240\u6709\u5df2\u8ddf\u8e2a\u53d8\u5316\u90fd\u5c5e\u4e8e\u540c\u4e00\u610f\u56fe&#xff0c;\u5e76\u4e14\u5df2\u7ecf\u786e\u8ba4\u8fc7\u73b0\u573a\u65f6&#xff0c;\u5b83\u624d\u6bd4\u8f83\u5408\u9002\u3002<\/p>\n<h3>\u4e00\u6b21\u63d0\u4ea4\u524d\u540e\u7684\u7a33\u5b9a\u68c0\u67e5\u987a\u5e8f<\/h3>\n<p>git status &#8211;short<br \/>\n  \u2193<br \/>\ngit diff<br \/>\n  \u2193<br \/>\n\u6392\u9664\u4e0d\u5e94\u8ddf\u8e2a\u7684\u8def\u5f84&#xff0c;\u9009\u62e9\u672c\u6b21\u76f8\u5173\u53d8\u5316<br \/>\n  \u2193<br \/>\ngit diff &#8211;cached<br \/>\n  \u2193<br \/>\ngit commit<br \/>\n  \u2193<br \/>\ngit status &#8211;short<br \/>\n  \u2193<br \/>\ngit log &#8211;oneline \/ git show <\/p>\n<p>\u63d0\u4ea4\u4e4b\u524d\u68c0\u67e5\u9009\u62e9&#xff0c;\u63d0\u4ea4\u4e4b\u540e\u6838\u5bf9\u7ed3\u679c\u3002\u6682\u5b58\u533a\u4e0d\u662f\u5fc5\u987b\u673a\u68b0\u7ecf\u8fc7\u7684\u4e00\u6b65&#xff0c;\u800c\u662f\u7f16\u8f91\u4e0b\u4e00\u6b21\u5386\u53f2\u8bb0\u5f55\u7684\u5730\u65b9\u3002<\/p>\n<h3>\u603b\u7ed3<\/h3>\n<p>\u4e00\u6b21\u6e05\u6670\u7684\u63d0\u4ea4\u4e0d\u662f\u9760\u4e00\u53e5\u6f02\u4eae\u7684\u63d0\u4ea4\u8bf4\u660e\u4ea7\u751f\u7684&#xff0c;\u800c\u662f\u4ece\u68c0\u67e5\u73b0\u573a\u3001\u6392\u9664\u65e0\u5173\u6587\u4ef6\u3001\u9009\u62e9\u540c\u4e00\u610f\u56fe\u7684\u53d8\u5316\u5f00\u59cb\u3002status \u5b9a\u4f4d\u8def\u5f84&#xff0c;diff \u6838\u5bf9\u5185\u5bb9&#xff0c;\u6682\u5b58\u533a\u786e\u5b9a\u8fb9\u754c&#xff0c;log \u548c show \u5219\u5e2e\u52a9\u786e\u8ba4\u6700\u7ec8\u5199\u5165\u4e86\u600e\u6837\u7684\u5386\u53f2\u3002<\/p>\n<h3>\u53c2\u8003\u8d44\u6599<\/h3>\n<ul>\n<li>Git \u5b98\u65b9\u8d44\u6599&#xff1a;Recording Changes to the Repository<\/li>\n<li>Git \u5b98\u65b9\u8d44\u6599&#xff1a;Viewing the Commit History<\/li>\n<li>Git \u5b98\u65b9\u6587\u6863&#xff1a;git-status<\/li>\n<li>Git \u5b98\u65b9\u6587\u6863&#xff1a;git-diff<\/li>\n<li>Git \u5b98\u65b9\u6587\u6863&#xff1a;git-add<\/li>\n<li>Git \u5b98\u65b9\u6587\u6863&#xff1a;git-commit<\/li>\n<li>Git \u5b98\u65b9\u6587\u6863&#xff1a;git-log<\/li>\n<li>Git \u5b98\u65b9\u6587\u6863&#xff1a;git-show<\/li>\n<li>Git \u5b98\u65b9\u6587\u6863&#xff1a;gitignore<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u4ece\u666e\u901a\u76ee\u5f55\u5b8c\u6210\u7b2c\u4e00\u6b21\u672c\u5730\u63d0\u4ea4\u5e76\u4e0d\u96be&#xff0c;\u4f46\u771f\u5b9e\u5f00\u53d1\u5f88\u5c11\u4e00\u76f4\u4fdd\u6301\u201c\u53ea\u4fee\u6539\u4e00\u4e2a\u6587\u4ef6&#xff0c;\u7136\u540e\u7acb\u5373\u63d0\u4ea4\u201d\u7684\u7406\u60f3\u72b6\u6001\u3002<br \/>\n\u5199\u4e00\u4e2a\u529f\u80fd\u65f6\u53ef\u80fd\u540c\u65f6\u51fa\u73b0&#xff1a;<br \/>\n\u5f53\u524d\u771f\u6b63\u8981\u63d0\u4ea4\u7684\u4ee3\u7801&#xff1b;\u987a\u624b\u4fee\u6539\u4f46\u5e94\u5355\u72ec\u63d0\u4ea4\u7684\u6587\u6863&#xff1b;\u8fd0\u884c\u7a0b\u5e8f\u4ea7\u751f\u7684\u65e5\u5fd7&#xff1b;\u53ea\u5c5e\u4e8e\u672c\u673a\u7684\u73af\u5883\u914d\u7f6e\u3002<br \/>\n\u8fd9\u65f6&#xff0c;add \u548c commit \u672c\u8eab\u5e76\u4e0d\u96be&#xff0c;\u771f\u6b63\u9700\u8981\u5224\u65ad\u7684\u662f&#xff1a; \u54ea\u4e9b\u53d8\u5316\u5c5e\u4e8e\u8fd9\u6b21\u63d0\u4ea4&#xff0c;\u54ea\u4e9b\u5e94\u8be5\u7559\u5728\u5916\u9762&amp;#x<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[9099,89],"topic":[],"class_list":["post-87165","post","type-post","status-publish","format-standard","hentry","category-server","tag-9099","tag-git"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>04.\u4e00\u6b21 Git \u63d0\u4ea4\u524d\u540e\uff0c\u5e94\u8be5\u68c0\u67e5\u4ec0\u4e48\uff1f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/87165.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"04.\u4e00\u6b21 Git \u63d0\u4ea4\u524d\u540e\uff0c\u5e94\u8be5\u68c0\u67e5\u4ec0\u4e48\uff1f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4ece\u666e\u901a\u76ee\u5f55\u5b8c\u6210\u7b2c\u4e00\u6b21\u672c\u5730\u63d0\u4ea4\u5e76\u4e0d\u96be&#xff0c;\u4f46\u771f\u5b9e\u5f00\u53d1\u5f88\u5c11\u4e00\u76f4\u4fdd\u6301\u201c\u53ea\u4fee\u6539\u4e00\u4e2a\u6587\u4ef6&#xff0c;\u7136\u540e\u7acb\u5373\u63d0\u4ea4\u201d\u7684\u7406\u60f3\u72b6\u6001\u3002 \u5199\u4e00\u4e2a\u529f\u80fd\u65f6\u53ef\u80fd\u540c\u65f6\u51fa\u73b0&#xff1a; \u5f53\u524d\u771f\u6b63\u8981\u63d0\u4ea4\u7684\u4ee3\u7801&#xff1b;\u987a\u624b\u4fee\u6539\u4f46\u5e94\u5355\u72ec\u63d0\u4ea4\u7684\u6587\u6863&#xff1b;\u8fd0\u884c\u7a0b\u5e8f\u4ea7\u751f\u7684\u65e5\u5fd7&#xff1b;\u53ea\u5c5e\u4e8e\u672c\u673a\u7684\u73af\u5883\u914d\u7f6e\u3002 \u8fd9\u65f6&#xff0c;add \u548c commit \u672c\u8eab\u5e76\u4e0d\u96be&#xff0c;\u771f\u6b63\u9700\u8981\u5224\u65ad\u7684\u662f&#xff1a; \u54ea\u4e9b\u53d8\u5316\u5c5e\u4e8e\u8fd9\u6b21\u63d0\u4ea4&#xff0c;\u54ea\u4e9b\u5e94\u8be5\u7559\u5728\u5916\u9762&amp;#x\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/87165.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-07-29T15:24:43+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/87165.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/87165.html\",\"name\":\"04.\u4e00\u6b21 Git \u63d0\u4ea4\u524d\u540e\uff0c\u5e94\u8be5\u68c0\u67e5\u4ec0\u4e48\uff1f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-07-29T15:24:43+00:00\",\"dateModified\":\"2026-07-29T15:24:43+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/87165.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/87165.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/87165.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"04.\u4e00\u6b21 Git \u63d0\u4ea4\u524d\u540e\uff0c\u5e94\u8be5\u68c0\u67e5\u4ec0\u4e48\uff1f\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"04.\u4e00\u6b21 Git \u63d0\u4ea4\u524d\u540e\uff0c\u5e94\u8be5\u68c0\u67e5\u4ec0\u4e48\uff1f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/87165.html","og_locale":"zh_CN","og_type":"article","og_title":"04.\u4e00\u6b21 Git \u63d0\u4ea4\u524d\u540e\uff0c\u5e94\u8be5\u68c0\u67e5\u4ec0\u4e48\uff1f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4ece\u666e\u901a\u76ee\u5f55\u5b8c\u6210\u7b2c\u4e00\u6b21\u672c\u5730\u63d0\u4ea4\u5e76\u4e0d\u96be&#xff0c;\u4f46\u771f\u5b9e\u5f00\u53d1\u5f88\u5c11\u4e00\u76f4\u4fdd\u6301\u201c\u53ea\u4fee\u6539\u4e00\u4e2a\u6587\u4ef6&#xff0c;\u7136\u540e\u7acb\u5373\u63d0\u4ea4\u201d\u7684\u7406\u60f3\u72b6\u6001\u3002 \u5199\u4e00\u4e2a\u529f\u80fd\u65f6\u53ef\u80fd\u540c\u65f6\u51fa\u73b0&#xff1a; \u5f53\u524d\u771f\u6b63\u8981\u63d0\u4ea4\u7684\u4ee3\u7801&#xff1b;\u987a\u624b\u4fee\u6539\u4f46\u5e94\u5355\u72ec\u63d0\u4ea4\u7684\u6587\u6863&#xff1b;\u8fd0\u884c\u7a0b\u5e8f\u4ea7\u751f\u7684\u65e5\u5fd7&#xff1b;\u53ea\u5c5e\u4e8e\u672c\u673a\u7684\u73af\u5883\u914d\u7f6e\u3002 \u8fd9\u65f6&#xff0c;add \u548c commit \u672c\u8eab\u5e76\u4e0d\u96be&#xff0c;\u771f\u6b63\u9700\u8981\u5224\u65ad\u7684\u662f&#xff1a; \u54ea\u4e9b\u53d8\u5316\u5c5e\u4e8e\u8fd9\u6b21\u63d0\u4ea4&#xff0c;\u54ea\u4e9b\u5e94\u8be5\u7559\u5728\u5916\u9762&amp;#x","og_url":"https:\/\/www.wsisp.com\/helps\/87165.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-07-29T15:24:43+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/87165.html","url":"https:\/\/www.wsisp.com\/helps\/87165.html","name":"04.\u4e00\u6b21 Git \u63d0\u4ea4\u524d\u540e\uff0c\u5e94\u8be5\u68c0\u67e5\u4ec0\u4e48\uff1f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-07-29T15:24:43+00:00","dateModified":"2026-07-29T15:24:43+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/87165.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/87165.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/87165.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"04.\u4e00\u6b21 Git \u63d0\u4ea4\u524d\u540e\uff0c\u5e94\u8be5\u68c0\u67e5\u4ec0\u4e48\uff1f"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/87165","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=87165"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/87165\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=87165"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=87165"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=87165"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=87165"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}