{"id":6721,"date":"2025-09-29T13:42:33","date_gmt":"2025-09-29T05:42:33","guid":{"rendered":"https:\/\/xinchewhd.com.cn\/?p=6721"},"modified":"2025-09-29T13:42:40","modified_gmt":"2025-09-29T05:42:40","slug":"git%e7%89%88%e6%9c%ac%e6%8e%a7%e5%88%b6%e7%b3%bb%e7%bb%9f%c2%b7%e5%b8%b8%e8%a7%81%e7%9a%84%e5%91%bd%e4%bb%a4","status":"publish","type":"post","link":"https:\/\/xinchewhd.com.cn\/index.php\/git\/git%e7%89%88%e6%9c%ac%e6%8e%a7%e5%88%b6%e7%b3%bb%e7%bb%9f%c2%b7%e5%b8%b8%e8%a7%81%e7%9a%84%e5%91%bd%e4%bb%a4\/","title":{"rendered":"Git\u7248\u672c\u63a7\u5236\u7cfb\u7edf\u00b7\u5e38\u89c1\u7684\u547d\u4ee4"},"content":{"rendered":"\n<p>\u300a\u672c\u6587\u4e3a\u6570\u636e\u79d1\u5b66\u4e4b\u7f16\u7a0b\u6280\u672f\u300bGit\u7ae0\u8282\u7684\u7b14\u8bb0\u5408\u96c6<\/p>\n\n\n\n<p>One of the most import parts of writing code to work with data is keeping track of changes to your code. Maintaining a clear and well-documented history of your work is crucial for transparency and collaboration. Even if you are working independently, tracking your changes will enable you to revert to earlier versions of your project and more easily identify errors.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">\u4ec0\u4e48\u662fGit<\/h5>\n\n\n\n<p>A version control system (VCS) is a tool for managing a collection of program code that provides you with three important capabilities: reversibility, concurrency, and annotation.<\/p>\n\n\n\n<p>where git really comes in handy is in team development<\/p>\n\n\n\n<p>Git\u7684\u6838\u5fc3<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4ed3\u5e93(repo) \uff1a\u4fdd\u5b58\u5728\u9879\u76ee\u76ee\u5f55\u4e0b\u540d\u4e3a.git\u7684\u9690\u85cf\u5b50\u76ee\u5f55\u4e2d\u3002If you want to sound cool and in-the-know, call the project folder itself a \u201crepo\u201d<\/li>\n\n\n\n<li>\u63d0\u4ea4 \uff1a\u88ab\u6dfb\u52a0\u5230\u4ed3\u5e93(\u4ee5\u6570\u636e\u5e93\u4fdd\u5b58)\u7684\u67d0\u4e2a\u65f6\u95f4\u70b9\u7684\u5de5\u4f5c\u5feb\u7167\uff0c\u6216\u68c0\u67e5\u70b9<\/li>\n\n\n\n<li>\u8fdc\u7a0b \uff1a\u6307\u5411\u975e\u672c\u673a\u4e0a\u4ed3\u5e93\u526f\u672c\u7684\u94fe\u63a5\u3002\u8be5\u94fe\u63a5\u6307\u5411\u4e86Web\u4e0a\u526f\u672c\u5b58\u50a8\u7684\u4f4d\u7f6e You can push (upload) commits to, and pull (download) commits from, a remote repository to keep everything in sync.<\/li>\n\n\n\n<li>\u5408\u5e76\uff1agit\u652f\u6301\u591a\u4e2a\u4e0d\u540c\u7248\u672c\u7684\u5de5\u4f5c,\u6240\u6709\u7248\u672c\u5e76\u884c\u5b58\u5728\u7740(\u5728\u6240\u8c13\u7684\u5206\u652f\u4e2d)\uff0c\u8fd9\u4e9b\u7248\u672c\u53ef\u4ee5\u7531\u4e00\u4e2a\u4eba\u6216\u591a\u4e2a\u5408\u4f5c\u8005\u521b\u5efa\u3002Git supports having multiple different versions of your work that all live side by side (in what are called branches), which may be created by one person or by many collaborators.<\/li>\n<\/ul>\n\n\n\n<p>Git was created to support completely decentralized development, in which developers pull commits (sets of changes) from one another\u2019s machines directly.<\/p>\n\n\n\n<p>GitHub\u662f\u4e00\u4e2a\u4e91\u6258\u7ba1\u9879\u76ee\u526f\u672c\u7684\u7f51\u7ad9,\u652f\u6301\u591a\u4eba\u534f\u4f5c(\u4f7f\u7528git)\u3002GitHub is a site that will host a copy of your project in the cloud, enabling multiple people to collaborate (using git). git\u7528\u6765\u505a\u7248\u672c\u63a7\u5236\uff1bGitHub\u662f\u4e00\u4e2a\u53ef\u4ee5\u7528\u6765\u4fdd\u5b58\u4ee3\u7801\u4ed3\u5e93\u7684\u5730\u65b9\u3002<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">\u914d\u7f6e\u548c\u9879\u76ee\u8bbe\u7f6e<\/h5>\n\n\n\n<p>\u5b89\u88c5\u540e\u7b2c\u4e00\u6b21\u4f7f\u7528git\uff0c\u9700\u8981\u914d\u7f6e\u7528\u6237\u4fe1\u606f,\u4ee5\u4fbf\u4f60\u80fd\u591f\u5411\u4ed3\u5e93\u63d0\u4ea4\u66f4\u6539\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#&nbsp;Configure&nbsp;'git'&nbsp;on&nbsp;your&nbsp;machine(only&nbsp;needs&nbsp;to&nbsp;be&nbsp;done&nbsp;once)<br><br>#&nbsp;Set&nbsp;your&nbsp;name&nbsp;to&nbsp;appear&nbsp;alongside&nbsp;your&nbsp;commits<br>#This&nbsp;*does&nbsp;not*&nbsp;need&nbsp;to&nbsp;be&nbsp;your&nbsp;GitHub&nbsp;username<br>git&nbsp;config&nbsp;--global&nbsp;user.name&nbsp;\"YOUR&nbsp;FULLNAME\"<br><br>#&nbsp;Set&nbsp;your&nbsp;email&nbsp;address<br>#&nbsp;This&nbsp;*does&nbsp;not*&nbsp;need&nbsp;to&nbsp;be&nbsp;the&nbsp;email&nbsp;associated&nbsp;with&nbsp;your&nbsp;GitHub&nbsp;accout<br><br>git&nbsp;config&nbsp;--globel&nbsp;user.email&nbsp;\"YOUR_EMAIL_ADDRESS\"<br><\/code><\/pre>\n\n\n\n<p>\u914d\u7f6e\u5b8c\u6210\u7528\u6237\u4fe1\u606f\u540e,\u6bcf\u5929\u5f80GitHub\u63d0\u4ea4\u4ee3\u7801\u4ecd\u65e7\u9700\u8981\u8f93\u5165\u5bc6\u7801\uff0c\u4e3aGitHub\u8bbe\u7f6e\u4e00\u4e2assh\u5bc6\u5319\u53ef\u8282\u7701\u4e00\u4e9b\u65f6\u95f4\u3002Generating a new SSH key<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">\u751f\u6210\u4e00\u4e2a\u4ed3\u5e93<\/h6>\n\n\n\n<pre class=\"wp-block-code\"><code>#&nbsp;Create&nbsp;a&nbsp;new&nbsp;folder&nbsp;in&nbsp;your&nbsp;current&nbsp;location&nbsp;called&nbsp;`learning_git`<br>mkdir&nbsp;learning_git<br><br>#&nbsp;Change&nbsp;your&nbsp;current&nbsp;directory&nbsp;to&nbsp;the&nbsp;new&nbsp;folder&nbsp;you&nbsp;just&nbsp;created<br>cd&nbsp;learning_git<br><br>#&nbsp;Initialize&nbsp;a&nbsp;new&nbsp;repository&nbsp;inside&nbsp;your&nbsp;'learning_git'&nbsp;folder<br>git&nbsp;init<\/code><\/pre>\n\n\n\n<p>git init \u547d\u4ee4\u5728\u5f53\u524d\u76ee\u5f55\u65b0\u5efa\u4e86\u4e00\u4e2a.git\u7684\u9690\u85cf\u6587\u4ef6\u5939\u3002\u56e0\u4e3a\u662f\u9690\u85cf\u7684\uff0c\u67e5\u627e\u5668\u67e5\u4e0d\u5230\u8be5\u6587\u4ef6\u5939\uff0c\u4f46\u662f\u7528ls -a(\u5e26all\u53c2\u6570\u7684\"list\"\u547d\u4ee4)\u53ef\u770b\u5230\u3002\u8be5\u6587\u4ef6\u5939\u662f\u6240\u4f5c\u6539\u52a8\u7684\u201c\u6570\u636e\u5e93\u201d,git\u5c06\u4fdd\u5b58\u8fd9\u4e2a\u6587\u4ef6\u5939\u4e2d\u6240\u6709\u63d0\u4ea4\u7684\u6539\u52a8\u3002\u5305\u542b.git\u7684\u6587\u4ef6\u5939\u4f1a\u5c06\u4e00\u4e2a\u76ee\u5f55\u8f6c\u6362\u6210\u4e00\u4e2a\u4ed3\u5e93,\u4f60\u53ef\u5c06\u6574\u4e2a\u76ee\u5f55\u79f0\u4e3a\u201crepo\u201d<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">\u68c0\u67e5\u72b6\u6001<\/h6>\n\n\n\n<p>\u521b\u5efa\u5b8crepo\u540e,\u4e0b\u9762\u5c06\u4f1a\u4ecb\u7ecd\u5982\u4f55\u68c0\u67e5\u4ed6\u7684\u72b6\u6001<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#&nbsp;Check&nbsp;the&nbsp;status&nbsp;of&nbsp;your&nbsp;repository<br>#(this&nbsp;and&nbsp;other&nbsp;commands&nbsp;will&nbsp;only&nbsp;work&nbsp;inside&nbsp;git&nbsp;project&nbsp;folders)<br>git&nbsp;status<\/code><\/pre>\n\n\n\n<p>git status \u547d\u4ee4\u5c06\u663e\u793arepo\u7684\u72b6\u6001\u3002\u5728\u4e00\u4e2a\u65b0\u7684repo\u4e0a\uff0c\u6267\u884c\u8be5\u547d\u4ee4\u4f1a\u5217\u51fa\u4e0b\u9762\u7684\u4fe1\u606f\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>On&nbsp;branch&nbsp;master<br><br>No&nbsp;commits&nbsp;yet<br><br>nothing&nbsp;to&nbsp;commit(create\/copy&nbsp;files&nbsp;and&nbsp;use&nbsp;\"git&nbsp;add\"&nbsp;to&nbsp;track)<\/code><\/pre>\n\n\n\n<p>\u5728\u6574\u4e2a\u4f7f\u7528git\u8fc7\u7a0b\u4e2d,git status\u662f\u6700\u6709\u7528\u7684\u547d\u4ee4\u3002\u5728\u5b66\u4e60git\u57fa\u7840\u77e5\u8bc6\u65f6,\u5728\u6267\u884c\u547d\u4ee4\u524d\u540e\uff0c\u67e5\u770b\u4e00\u6b21\u9879\u76ee\u66f4\u6539\u72b6\u6001\u662f\u76f8\u5f53\u6709\u7528\u7684\u3002\u5b66\u4e60\u5b83\uff0c\u4f7f\u7528\u5b83\uff0c\u70ed\u7231\u5b83\u3002<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">\u8ddf\u8e2a\u9879\u76ee\u53d8\u66f4<\/h5>\n\n\n\n<h6 class=\"wp-block-heading\">\u6dfb\u52a0\u6587\u4ef6<\/h6>\n\n\n\n<p>\u7b2c\u4e00\u6b65\u662f\u5c06\u8fd9\u4e9b\u6539\u52a8\u6dfb\u52a0\u5230\u4e34\u65f6\u533a\u57df\u3002\u4e34\u65f6\u533a\u57df\u5c31\u50cf\u5728\u7ebf\u5546\u5e97\u7684\u8d2d\u7269\u8f66\uff1a\u5728\u66f4\u6539\u8bb0\u5f55\u63d0\u4ea4\u5230\u6570\u636e\u5e93\u4e4b\u524d(\u4f8b\u5982,\u5728\u70b9\u51fb\"\u8d2d\u4e70\"\u524d),\u5c06\u6539\u52a8\u653e\u5728\u4e34\u65f6\u5b58\u50a8\u533a\u4e2d\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#&nbsp;Add&nbsp;changes&nbsp;to&nbsp;a&nbsp;file&nbsp;with&nbsp;the&nbsp;name&nbsp;FILENAME&nbsp;to&nbsp;the&nbsp;staging&nbsp;area<br>#&nbsp;Replace&nbsp;FILENAME&nbsp;with&nbsp;the&nbsp;name&nbsp;of&nbsp;your&nbsp;file&nbsp;(e.g.&nbsp;books.txt)<br>git&nbsp;add&nbsp;FILENAME<\/code><\/pre>\n\n\n\n<p>\u8fd9\u4f1a\u5c06\u5904\u4e8e\u5f53\u524d\u4fdd\u5b58\u72b6\u6001\u7684\u5355\u4e2a\u6587\u4ef6\u6dfb\u52a0\u5230\u4e34\u65f6\u533a\u57df\u3002\u5982\u679c\u4ee5\u540e\u6539\u52a8\u8be5\u6587\u4ef6,\u9700\u8981\u518d\u6b21\u8fd0\u884cgit add\u547d\u4ee4\u6dfb\u52a0\u6587\u4ef6\u7684\u66f4\u65b0\u7248\u672c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#&nbsp;Add&nbsp;all&nbsp;saved&nbsp;contents&nbsp;of&nbsp;the&nbsp;directory&nbsp;to&nbsp;the&nbsp;staging&nbsp;area<br>git&nbsp;add&nbsp;.<br><br><\/code><\/pre>\n\n\n\n<h6 class=\"wp-block-heading\">\u63d0\u4ea4<\/h6>\n\n\n\n<p>\u5982\u679c\u5bf9\u4e34\u65f6\u533a\u57df\u7684\u5185\u5bb9\u611f\u5230\u6ee1\u610f(\u5373\u51c6\u5907\u8d2d\u4e70)\uff0c\u5c31\u5230\u63d0\u4ea4\u8fd9\u4e9b\u66f4\u6539\u7684\u65f6\u95f4\u4e86,\u5c06\u6587\u4ef6\u7684\u5feb\u7167\u4fdd\u5b58\u5230\u4ed3\u5e93\u6570\u636e\u5e93\u4e2d\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#&nbsp;Create&nbsp;a&nbsp;commit(checkpoint)&nbsp;of&nbsp;the&nbsp;changes&nbsp;in&nbsp;the&nbsp;staging&nbsp;area<br>#&nbsp;Replace&nbsp;\"Your&nbsp;message&nbsp;here\"&nbsp;with&nbsp;a&nbsp;more&nbsp;informative&nbsp;message<br>git&nbsp;commit&nbsp;-m&nbsp;\"sencond&nbsp;commit\"<br><\/code><\/pre>\n\n\n\n<p>\u63d0\u4ea4\u66f4\u6539\u5b8c\u6210\u540e,\u786e\u4fdd\u6838\u5bf9git status\u7684\u6267\u884c\u7ed3\u679c<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u5ba1\u6838\u672c\u5730git\u6d41\u7a0b<\/h4>\n\n\n\n<p>\u4f7f\u7528git\u7684\u6807\u51c6\"\u5f00\u53d1\u5faa\u73af\"\u662f\u7f16\u8f91\u6587\u4ef6\u3001\u6dfb\u52a0\u6587\u4ef6\u3001\u63d0\u4ea4\u66f4\u6539\u7684\u5faa\u73af \u901a\u5e38\uff0c\u4ee3\u7801\u8981\u505a\u5927\u91cf\u6539\u52a8(\u7f16\u8f91\u5927\u91cf\u6587\u4ef6\u3001\u8fd0\u884c\u548c\u6d4b\u8bd5\u4ee3\u7801\u7b49)\uff0c\u4e0d\u8fc7\u4e00\u65e6\u6709\u4e86\u597d\u7684\u201c\u65ad\u70b9\u201d,\u4e00\u65e6\u8981\u6dfb\u52a0\u548c\u63d0\u4ea4\u66f4\u6539,\u4ee5\u786e\u4fdd\u5de5\u4f5c\u4e0d\u4e22\u5e76\u80fd\u591f\u968f\u65f6\u56de\u5230\u8fd9\u4e2a\u201c\u65ad\u70b9\u201d\u4f4d\u7f6e\u3002\u201c\u65ad\u70b9\u201d\u53ef\u4ee5\u5b9e\u73b0\u4e86\u4e00\u4e2a\u529f\u80fd\u3001\u5361\u58f3\u4e86\u9700\u8981\u559d\u5496\u5561\u4e86\u6216\u662f\u8ba1\u5212\u8fdb\u884c\u5f7b\u5e95\u66f4\u6539\u3002\u6ce8\u610f:\u6bcf\u6b21\u63d0\u4ea4\u610f\u5473\u7740\u4e00\u7ec4\u6539\u52a8,\u901a\u5e38\u6ce2\u53ca\u591a\u4e2a\u6587\u4ef6.\u4e0d\u8981\u4e00\u4e2a\u6587\u4ef6\u7684\u4e00\u6b21\u6539\u52a8\u5c31\u63d0\u4ea4\u4e00\u6b21;\u76f8\u53cd\uff0c\u6bcf\u6b21\u63d0\u4ea4\u5e94\u8be5\u662f\u6574\u4e2a\u9879\u76ee\u7684\u5feb\u7167\u6280\u5de7:\u5982\u679c\u65e0\u610f\u4e2d\u6dfb\u52a0\u4e86\u4e0d\u60f3\u6dfb\u52a0\u7684\u6587\u4ef6,\u53ef\u901a\u8fc7git reset\u547d\u4ee4(\u6ca1\u6709\u53c2\u6570)\u4ece\u4e34\u65f6\u533a\u57df\u4e2d\u5220\u9664\u6240\u6709\u6dfb\u52a0\u8fc7\u7684\u6587\u4ef6\u3002\u5982\u679c\u65e0\u610f\u4e2d\u63d0\u4ea4\u4e86\u4e0d\u60f3\u63d0\u4ea4\u7684\u6587\u4ef6,\u53ef\u4f7f\u7528git reset --soft HEAD~1\u64a4\u9500\u63d0\u4ea4<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u5728GitHub\u4e2d\u5b58\u50a8\u9879\u76ee<\/h4>\n\n\n\n<p>git \u662f\u7528\u6765\u521b\u5efa\u548c\u7ba1\u7406\u4ed3\u5e93\u7684\uff0cGithub\u53ea\u662f\u5b58\u50a8\u4ed3\u5e93\u7684\u7f51\u7ad9\u3002<\/p>\n\n\n\n<p>\u5b66\u4f1a\u4e86\u5728\u672c\u5730\u4f7f\u7528git\u8ddf\u8e2a\u9879\u76ee\u540e,\u5c31\u4f1a\u5411\u4f7f\u7528\u4e0d\u540c\u7684\u8ba1\u7b97\u673a\u6765\u8bbf\u95ee\u9879\u76ee\u6216\u8005\u4e0e\u4ed6\u4eba\u5171\u4eab\u9879\u76ee\u3002\u8fd9\u4e2a\u65f6\u5019,\u5c31\u8be5\u4f7f\u7528GitHub\u4e86,GitHub\u63d0\u4f9b\u4e91\u5b58\u50a8\u4ed3\u5e93\u526f\u672c\u7684\u5728\u7ebf\u670d\u52a1\u3002Repositories stored on GitHub are examples of remotes: other repos that are linked to your local one. Each repo can have multiple remotes, and you can synchronize commits between them. Each remote has a URL associated with it (indicating where on the internet the remote copy of the repo can be found), but they are given \u201calias\u201d names\u2014similar to browser bookmarks. By convention, the remote repo stored on GitHub\u2019s servers is named origin, since it tends to be the \u201corigin\u201d of any code you\u2019ve started working on.<\/p>\n\n\n\n<p>\u672c\u5730\u4ed3\u5e93\u94fe\u63a5\u5230GitHub\u7684\u8fdc\u7a0b\u526f\u672c\u3002\u6267\u884c\u6b64\u64cd\u4f5c\u6709\u4e24\u4e2a\u5e38\u89c1\u7684\u8fc7\u7a0b: 1.\u5982\u679c\u5728\u672c\u5730\u8ba1\u7b97\u673a\u4e0a\u5df2\u7ecf\u5b58\u5728git\u8ddf\u8e2a\u8fc7\u7684\u9879\u76ee,\u901a\u8fc7\u5355\u51fbGitHub\u4e3b\u9875(\u9700\u8981\u767b\u5f55)\u4e0a\u7684\u7eff\u8272\"New Repository\"\u6309\u94ae\u65b0\u5efa\u4e00\u4e2arepo,\u8fd9\u4f1a\u5728\u5f53\u524dGitHub\u8d26\u6237\u4e0b\u65b0\u521b\u5efa\u4e00\u4e2a\u7a7a\u7684repo\u3002\u6309\u7167GitHub\u63d0\u4f9b\u7684\u6307\u4ee4\uff0c\u94fe\u63a5\u672c\u5730\u7684repo\u5230GitHub\u4e0a\u65b0\u5efa\u7684repo\u3002<\/p>\n\n\n\n<p>2.\u5982\u679cGitHub\u5b58\u5728\u4e00\u4e2a\u8981\u5728\u672c\u5730\u7f16\u8f91\u7684\u9879\u76ee,\u53ef\u5148\u514b\u9686(\u4e0b\u8f7d)GitHub\u4e0a\u7684repo\u526f\u672c,\u800c\u540e\u8fdb\u884c\u4fee\u6539\u548c\u7f16\u8f91\u4ee3\u7801\u3002\u56e0\u8be5\u8fc7\u7a0b\u8f83\u4e3a\u5e38\u89c1\uff0c\u6240\u4ee5\u8fd9\u91cc\u8fdb\u884c\u4e86\u8be6\u7ec6\u7684\u63cf\u8ff0.<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">\u5206\u652f\u548c\u514b\u9686<\/h6>\n\n\n\n<p>\u201cFork\u201d\u6309\u94ae\u5bf9\u4e00\u4e2arepo\u8fdb\u884c\u5206\u652f\u3002\u8fd9\u5c06repo\u590d\u5236\u5230\u81ea\u5df1GitHub\u4e0a\uff0c\u800c\u540e\u5c31\u80fd\u4e0b\u8f7d\u548c\u4e0a\u4f20\u66f4\u6539\u5230\u526f\u672c\u4e2d,\u4f46\u4e0d\u662f\u4e0a\u4f20\u5230\u6700\u539f\u59cb\u7684repo\u4e2d\u3002\u4f7f\u7528git clone \u547d\u4ee4\u4e0b\u8f7drepo\u5230\u81ea\u5df1\u7684\u76ee\u5f55\u4e2d:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#&nbsp;Change&nbsp;to&nbsp;the&nbsp;folder&nbsp;that&nbsp;will&nbsp;contain&nbsp;the&nbsp;downloaded&nbsp;repository&nbsp;folder<br>cd&nbsp;~\/Desktop<br><br>#Download&nbsp;the&nbsp;repository&nbsp;folder&nbsp;into&nbsp;the&nbsp;current&nbsp;directory<br>git&nbsp;clone&nbsp;REPO_URL<\/code><\/pre>\n\n\n\n<p>\u8be5\u547d\u4ee4\u5728\u5f53\u524d\u6587\u4ef6\u5939\u4e0b\u521b\u5efa\u4e86\u4e00\u4e2a\u65b0\u7684repo(\u76ee\u5f55),\u5e76\u5c06URL\u6307\u5b9a\u7684\u4ee3\u7801\u526f\u672c\u548c\u6240\u6709\u63d0\u4ea4\u4e0b\u8f7d\u5230\u65b0\u7684\u6587\u4ef6\u5939\u4e2d\u3002<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">\u63a8\u9001\u548c\u62c9\u53d6<\/h6>\n\n\n\n<p>\u4e00\u65e6\u6709\u4efdrepo\u4ee3\u7801\u7684\u526f\u672c,\u5c31\u53ef\u5728\u672c\u5730\u8ba1\u7b97\u673a\u4e0a\u66f4\u6539\u4ee3\u7801\uff0c\u968f\u540e\u5c06\u66f4\u6539\u63a8\u9001\u5927GitHub\u4e0a\u53ef\u4ee5\u3002After making changes, you will, of course, need to add the changed files to the staging area and commit the changes to the repo (don\u2019t forget the -m message!).<\/p>\n\n\n\n<p>\u4f7f\u7528\u7f16\u8f91\u5668\u4fee\u6539\u8fd9\u4e9b\u6587\u4ef6\uff0c\u4fee\u6539\u5b8c\u540e\uff0c\u5c31\u9700\u8981\u5c06\u6539\u52a8\u7684\u6587\u4ef6\u6dfb\u52a0\u5230\u4e34\u65f6\u533a\u57df\u4e2d,\u5e76\u63d0\u4ea4\u5230repo\u4e2d(\u4e0d\u8981\u5fd8\u8bb0\u4f7f\u7528-m\u53c2\u6570\u6dfb\u52a0\u5907\u6ce8) \u63d0\u4ea4\u5c06\u4fdd\u5b58\u66f4\u6539\u5230\u672c\u5730,\u4f46\u6ca1\u5c06\u8fd9\u4e9b\u66f4\u6539\u63a8\u9001\u5230GitHub\u4e0a\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#&nbsp;Push&nbsp;commits&nbsp;from&nbsp;your&nbsp;computer&nbsp;up&nbsp;to&nbsp;a&nbsp;remove&nbsp;server(e.g.,GitHub)<br>git&nbsp;push<\/code><\/pre>\n\n\n\n<p>\u8be5\u547d\u4ee4\u4f1a\u5c06\u5f53\u524d\u4ee3\u7801\u63a8\u9001\u5230\u539f\u59cb\u8fdc\u7a0b\u526f\u672c\u4e2d\uff08\u63a8\u9001\u5230\u526f\u672c\u4e2d\u7684\u4e3b\u5206\u652f\uff09\u4e0b\u9762\u547d\u4ee4\u53ef\u67e5\u770b\u8fdc\u7a0b\u4f4d\u7f6e\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#print&nbsp;out&nbsp;(verbosely)&nbsp;the&nbsp;remote&nbsp;location(s)<br>git&nbsp;remote&nbsp;-v<\/code><\/pre>\n\n\n\n<p>\u63a8\u9001\u5b8c\u5237\u65b0\u9875\u9762\u5373\u53ef\u770b\u5230\u66f4\u6539<\/p>\n\n\n\n<p>\u5982\u679c\u8981\u4e0b\u8f7d\u4ed6\u4eba\u505a\u7684\u66f4\u6539,\u53ef\u4f7f\u7528pull\u547d\u4ee4\u3002\u8be5\u547d\u4ee4\u5c06\u4eceGitHub\u4e0b\u8f7d\u66f4\u6539\u5e76\u5c06\u5176\u878d\u5408\u5230\u672c\u5730\u8ba1\u7b97\u673a\u4ee3\u7801\u4e2d<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#Pull&nbsp;changes&nbsp;down&nbsp;from&nbsp;a&nbsp;remove&nbsp;server(e.g.,GitHub)<br>git&nbsp;pull<br><\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"587\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929054218914-1024x587.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" alt=\"\" class=\"wp-image-6722 lazyload\" srcset=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929054218914-1024x587.png 1024w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929054218914-300x172.png 300w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929054218914-768x440.png 768w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929054218914.png 1075w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><noscript><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"587\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929054218914-1024x587.png\" alt=\"\" class=\"wp-image-6722\" srcset=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929054218914-1024x587.png 1024w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929054218914-300x172.png 300w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929054218914-768x440.png 768w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929054218914.png 1075w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/noscript><\/figure>\n\n\n\n<p>\u56e0\u4e3a\u62c9\u53d6\u4ee3\u7801\u8fc7\u7a0b\u5305\u542b\u5c06\u4e0d\u540c\u4ee3\u7801\u7248\u672c\u878d\u5408\u5230\u4e00\u8d77,\u4e00\u5b9a\u8981\u5f53\u5fc3\u878d\u5408\u51b2\u7a81<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">\u8bbf\u95ee\u9879\u76ee\u5386\u53f2<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>#&nbsp;Print&nbsp;out&nbsp;a&nbsp;repository's&nbsp;commit&nbsp;history<br>git&nbsp;log<br><\/code><\/pre>\n\n\n\n<p>\u6309\u987a\u5e8f\u5217\u51fa\u63d0\u4ea4\u7684\u6240\u6709\u5386\u53f2:\u6709\u63d0\u4ea4\u8005\u3001\u63d0\u4ea4\u5185\u5bb9\u548c\u63d0\u4ea4\u65f6\u95f4(\u6807\u8bc6HEAD\u662f\u6307\u6700\u8fd1\u7684\u63d0\u4ea4)<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">\u6062\u590d\u65e9\u671f\u7248\u672c<\/h6>\n\n\n\n<p>\u7248\u672c\u63a7\u5236\u7cfb\u7edf\u7684\u4e00\u4e2a\u4e3b\u8981\u4f18\u70b9\u662f\u53ef\u9006\u6027,\u5373\u5177\u6709\u201c\u64a4\u9500\u201d\u4e00\u4e2a\u9519\u8bef\u7684\u80fd\u529b \u4f7f\u7528checkout\u547d\u4ee4,\u53ef\u56de\u6eda\u5230\u6587\u4ef6\u7684\u65e7\u7248\u672c-<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#Print&nbsp;a&nbsp;list&nbsp;of&nbsp;commit&nbsp;hashes<br>git&nbsp;log&nbsp;--oneline<br><br>#Check(load)&nbsp;the&nbsp;version&nbsp;of&nbsp;the&nbsp;file&nbsp;from&nbsp;the&nbsp;given&nbsp;commit<br>git&nbsp;checkout&nbsp;COMMIT_HASH&nbsp;FILENAME<\/code><\/pre>\n\n\n\n<p>\u5c06COMMIT_HASH\u548cFILENAME\u5206\u522b\u66ff\u6362\u6210\u63d0\u4ea4ID\u7684\u54c8\u5e0c\u503c\u548c\u8981\u56de\u6eda\u7684\u6587\u4ef6\u3002<\/p>\n\n\n\n<p>git status:\u68c0\u67e5repo\u72b6\u6001<\/p>\n\n\n\n<p>git add:\u6dfb\u52a0\u6587\u4ef6\u5230\u4e34\u65f6\u533a\u57df&nbsp;<\/p>\n\n\n\n<p>git commit -m \"Message\"\uff1a\u63d0\u4ea4\u66f4\u6539&nbsp;<\/p>\n\n\n\n<p>git clone:\uff1a\u590d\u5236\u4e00\u4e2arepo \u5230\u672c\u5730\u8ba1\u7b97\u673a\u4e0a&nbsp;<\/p>\n\n\n\n<p>git push\uff1a\u4e0a\u4f20\u63d0\u4ea4\u5230GitHub\u4e2d&nbsp;<\/p>\n\n\n\n<p>git pull\uff1a\u4eceGitHub\u4e0a\u4e0b\u8f7d\u63d0\u4ea4<\/p>\n\n\n\n<p>\u521d\u6b21\u63a8\u9001\u5230Github<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"500\" height=\"1024\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929054225333-500x1024.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" alt=\"\" class=\"wp-image-6723 lazyload\" srcset=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929054225333-500x1024.png 500w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929054225333-147x300.png 147w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929054225333-768x1573.png 768w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929054225333-750x1536.png 750w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929054225333.png 883w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><noscript><img loading=\"lazy\" decoding=\"async\" width=\"500\" height=\"1024\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929054225333-500x1024.png\" alt=\"\" class=\"wp-image-6723\" srcset=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929054225333-500x1024.png 500w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929054225333-147x300.png 147w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929054225333-768x1573.png 768w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929054225333-750x1536.png 750w, https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929054225333.png 883w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/noscript><\/figure>\n\n\n\n<p>\u518d\u6b21\u63a8\u9001\u5230Github<img decoding=\"async\" class=\"lazyload\"data-src=\"https:\/\/mmbiz.qpic.cn\/mmbiz_png\/HcP2onPXzrHK5VNicbicG2kLibTEictlOuxFEicabicuiblHKd105VdZMFpLkZF9xkuFw1JgafvpIvejX8ba3kJm5ZLvw\/640?wx_fmt=png&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1#imgIndex=2\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" alt=\"\u56fe\u7247\"><noscript><img decoding=\"async\" src=\"https:\/\/mmbiz.qpic.cn\/mmbiz_png\/HcP2onPXzrHK5VNicbicG2kLibTEictlOuxFEicabicuiblHKd105VdZMFpLkZF9xkuFw1JgafvpIvejX8ba3kJm5ZLvw\/640?wx_fmt=png&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1#imgIndex=2\" alt=\"\u56fe\u7247\"><\/noscript><\/p>\n","raw":"","protected":false},"excerpt":{"rendered":"<p>\u300a\u672c\u6587\u4e3a\u6570\u636e\u79d1\u5b66\u4e4b\u7f16\u7a0b\u6280\u672f\u300bGit\u7ae0\u8282\u7684\u7b14\u8bb0\u5408\u96c6 One of the most import parts of writing  &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[40],"tags":[],"class_list":["post-6721","post","type-post","status-publish","format-standard","hentry","category-git"],"post_thumbnail_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929054218914.png","content_first_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929054218914.png","post_medium_image_300":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929054218914.png","post_thumbnail_image_624":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929054218914.png","post_frist_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929054218914.png","post_medium_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929054218914.png","post_large_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929054218914.png","post_full_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929054218914.png","post_all_images":[{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929054218914-1024x587.png","id":"image0"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929054218914-1024x587.png","id":"image1"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929054225333-500x1024.png","id":"image2"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2025\/09\/20250929054225333-500x1024.png","id":"image3"},{"imagesurl":"https:\/\/mmbiz.qpic.cn\/mmbiz_png\/HcP2onPXzrHK5VNicbicG2kLibTEictlOuxFEicabicuiblHKd105VdZMFpLkZF9xkuFw1JgafvpIvejX8ba3kJm5ZLvw\/640?wx_fmt=png&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1#imgIndex=2","id":"image4"},{"imagesurl":"https:\/\/mmbiz.qpic.cn\/mmbiz_png\/HcP2onPXzrHK5VNicbicG2kLibTEictlOuxFEicabicuiblHKd105VdZMFpLkZF9xkuFw1JgafvpIvejX8ba3kJm5ZLvw\/640?wx_fmt=png&amp;tp=wxpic&amp;wxfrom=5&amp;wx_lazy=1#imgIndex=2","id":"image5"}],"videoAdId":"","listAd":"0","listAdId":"","listAdEvery":6,"total_comments":0,"category_name":"Git","post_date":"2025-09-29","like_count":"0","praiseWord":"\u9f13\u52b1","copyright_state":"","excitationAd":"0","rewardedVideoAdId":"","detailAdId":"","detailAd":"0","enterpriseMinapp":"0","audios":[],"postImageUrl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230519082947553.jpg","avatarurls":[],"related_posts":null,"pageviews":182,"next_post_id":null,"next_post_title":null,"previous_post_id":3742,"previous_post_title":"Git\u63d0\u4ea4\u4ee3\u7801\u4e22\u5931","_links":{"self":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/6721","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/comments?post=6721"}],"version-history":[{"count":1,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/6721\/revisions"}],"predecessor-version":[{"id":6724,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/6721\/revisions\/6724"}],"wp:attachment":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/media?parent=6721"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/categories?post=6721"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/tags?post=6721"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}