{"id":398,"date":"2024-10-24T10:52:44","date_gmt":"2024-10-24T02:52:44","guid":{"rendered":"https:\/\/eve2333.top\/?p=398"},"modified":"2024-10-24T11:20:51","modified_gmt":"2024-10-24T03:20:51","slug":"git%e7%9a%84%e5%9f%ba%e6%9c%ac%e4%bd%bf%e7%94%a8","status":"publish","type":"post","link":"https:\/\/eve2333.top\/?p=398","title":{"rendered":"git\u7684\u57fa\u672c\u4f7f\u7528"},"content":{"rendered":"\n<p>Git \u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u5206\u5e03\u5f0f\u7248\u672c\u63a7\u5236\u7cfb\u7edf\uff0c\u7528\u4e8e\u654f\u6377\u9ad8\u6548\u5730\u5904\u7406\u4efb\u4f55\u6216\u5c0f\u6216\u5927\u7684\u9879\u76ee\u3002<\/p>\n\n\n\n<p>Git \u662f Linus Torvalds \u4e3a\u4e86\u5e2e\u52a9\u7ba1\u7406 Linux \u5185\u6838\u5f00\u53d1\u800c\u5f00\u53d1\u7684\u4e00\u4e2a\u5f00\u653e\u6e90\u7801\u7684\u7248\u672c\u63a7\u5236\u8f6f\u4ef6\u3002<\/p>\n\n\n\n<p>Git \u4e0e\u5e38\u7528\u7684\u7248\u672c\u63a7\u5236\u5de5\u5177 CVS, Subversion \u7b49\u4e0d\u540c\uff0c\u5b83\u91c7\u7528\u4e86\u5206\u5e03\u5f0f\u7248\u672c\u5e93\u7684\u65b9\u5f0f\uff0c\u4e0d\u5fc5\u670d\u52a1\u5668\u7aef\u8f6f\u4ef6\u652f\u6301\u3002<\/p>\n\n\n\n<p>git\u7684\u4f7f\u7528\u8bf4\u91cd\u8981\u4e5f\u4e0d\u91cd\u8981\uff0c\u5728CS61b\u5f00\u8bfe\u5c31\u6559\u4e86\uff0cCSwiki\u4e5f\u5efa\u8bae\u5927\u4e00\u5f00\u5b66\u5c31\u5b66\uff0cnju\u7b49\u4e00\u7cfb\u5217985\u4e5f\u5927\u4e00\u5c31\u5b66\uff0c\u4f46\u662f\u4e0d\u5b66\u4e5f\u4e0d\u4f1a\u600e\u4e48\u6837\uff0c\u8fd9\u6bd5\u7adf\u53ea\u662f\u5de5\u5177\u4e0d\u662f\u77e5\u8bc6\uff0c\u5927\u4e0d\u4e86\u5de5\u4f4d\u4e0a\u968f\u4fbf\u770b\u4e00\u770b\u5c31\u884c\u5417\uff0c\u4ec1\u8005\u89c1\u4ec1\u55bd<br>\u5ed6\u96ea\u5cf0\u7684\u5b98\u65b9\u7f51\u7ad9-Git\uff1a<code>https:\/\/www.liaoxuefeng.com\/wiki\/896043488029600<\/code><\/p>\n\n\n\n<p>git\u7684\u57fa\u672c\u547d\u4ee4\u53ef\u76f4\u63a5\u770b\u6700\u4e0b\u65b9\u603b\u7ed3\uff08\u70b9\u51fb\u53f3\u4fa7\u5bfc\u822a\u680f\uff09<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u8bbe\u7f6e\u7528\u6237\uff08\u76ee\u7684\u5728\u4e8e\u53ef\u4ee5\u5728\u8fdc\u7aef\u770b\u5230\u662f\u8c01\u63d0\u4ea4\u4e86\u5185\u5bb9\uff0c\u66f4\u65b9\u4fbf\u516c\u53f8\u7684\u7ba1\u7406\uff09\n1\u3001\u8bbe\u7f6e\u5168\u5c40\u7528\u6237\uff08\u5728\u5bb6\u8def\u5f84\u4e0b\u521b\u5efa\u7528\u6237\uff0c\u6bcf\u4e2a\u9879\u76ee\u90fd\u7528\u8fd9\u4e00\u4e2a\u7528\u6237\uff09\n&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&gt;: git config --global user.name 'manba '\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&gt;: git config --global user.email 'manba@163.com'\n2\u3001\u8bbe\u7f6e\u5c40\u90e8\u7528\u6237\uff08\u5c40\u90e8\u662f\u6307\u5728\u67d0\u4e2a\u9879\u76ee\u4e0b\u521b\u5efa\u7528\u6237\uff0c\u53ef\u4ee5\u5728\u4e0d\u540c\u9879\u76ee\u4e0b\u521b\u5efa\u4e0d\u540c\u7528\u6237\uff09\n&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&gt;: git config &nbsp;user.name 'manba '\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&gt;: git config &nbsp;user.email 'manba@163.com'\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\n\u521d\u59cb\u5316\u4ed3\u5e93\uff0c\u8ba9git\u63a5\u7ba1\u4f60\u7684\u9879\u76ee\ngit init\n\n\u67e5\u770b\u6709\u4ec0\u4e48\u6587\u4ef6\nll\n\n\u67e5\u770b\u4ed3\u5e93\u72b6\u6001\ngit status\n&nbsp;&nbsp; &nbsp;-\u7ea2\u8272\uff1a\u65b0\u5efa\uff0c\u4fee\u6539\uff0c\u5220\u9664\uff0c\u5728\u5de5\u4f5c\u533a\u6ca1\u6709\u653e\u5230\u6682\u5b58\u533a\n&nbsp;&nbsp; &nbsp;-\u7eff\u8272\uff1a\u653e\u5230\u6682\u5b58\u533a\uff0c\u6ca1\u6709\u63d0\u4ea4\u5230\u7248\u672c\u5e93\n&nbsp;&nbsp; &nbsp;-\u6ca1\u6709\u4e1c\u897f\uff1a\u8bf4\u660e\u6240\u6709\u53d8\u66f4\u90fd\u88ab\u7248\u672c\u7ba1\u7406\u8d77\u6765\u4e86\n\n\u5c06\u5f53\u524d\u8def\u5f84\u4e0b\u7684\u6240\u6709\u53d8\u66f4\u63d0\u4ea4\u5230\u6682\u5b58\u533a\ngit add .\n\n\u5220\u9664\u6587\u4ef6\ngit rm --cached hello.txt&nbsp;\n\n\u5c06\u6682\u5b58\u533a\u7684\u5185\u5bb9\u63d0\u4ea4\u5230\u7248\u672c\u5e93\ngit commit -m \"THIS IS MY CODE\" HELLO.txt \n\n\u6253\u5370\u6b64\u6587\u4ef6\ncat hello.txt\n\n\u5728git\u91cc\u9762\u4fee\u6539\nvim hello.txt\n\u8fdb\u5165io\u754c\u9762\n\/\/\u6ce8\u610f\u8001\u5e08\u7528\u7684\u662fvim\u5b66\u751f\u9636\u6bb5\u4e0d\u63a8\u8350\u5b66\u4e60vim\u56e0\u4e3avim\u5b66\u4e60\u6210\u672c\u9ad8\uff0c\n\u5b66\u4e60\u5f88\u957f\u65f6\u95f4\u624d\u80fd\u770b\u5230\u6b63\u9762\u53cd\u9988\uff0c\u663e\u7136\u8fd9\u5bf9\u4e8e\u5b66\u751f\u6765\u8bf4\u662f\u4e0d\u597d\u7684\uff0c\n\u8981\u627e\u5230\u5de5\u4f5c\u5728\u5b66\u4e0d\u8fdf\uff0c\u5b66\u751f\u9636\u6bb5\u4e0d\u7528\u7422\u78e8\u8fd9\u4e2a\/\/\n\u70b9\u4e00\u4e0b\u952e\u76d8i\uff0c\u4fee\u6539\u5185\u5bb9\nvi\u540e\u8f93\u5165i\u8868\u793a\u8fdb\u5165\u7f16\u8f91\u6a21\u5f0f\uff0c\u8f93\u5165\u5b8c\u6bd5\u540e\u6309esc\u952e\u9000\u51fa\u7f16\u8f91\u6a21\u5f0f\uff0c\n\u8f93\u5165\u201c\uff1awq\u201d\u8868\u793a\u4fdd\u5b58\u5e76\u63a8\u51fa\uff0c\u90fd\u662flinux\u7684\u57fa\u672c\u64cd\u4f5c\uff0c\u53ef\u4ee5\u5148\u53bb\u5b66\u4e60Linux\n \n\u67e5\u770b\u7248\u672c\u7ba1\u7406\u65e5\u5fd7\ngit log &nbsp; # \u663e\u793a\u4f5c\u8005\uff0c\u7248\u672c\u53f7\uff0c\u6ce8\u91ca\ngit reflog &nbsp;# \u663e\u793a\u7cbe\u7b80\u4fe1\u606f\uff08\u7248\u672c\u5207\u6362\u4e5f\u4f1a\u663e\u793a\uff09\n\n\u7248\u672c\u7a7f\u68ad\n\u64a4\u9500\u7248\u672c\u5e93\u63d0\u4ea4\uff0c\u56de\u5230\u539f\u6709\u7684\u7248\u672c\u5f53\u4e2d\u53bb\ngit reset --hard \u7248\u672c\u53f7\n\n\u64a4\u9500\u5de5\u4f5c\u533a\u64cd\u4f5c\ngit checkout .\n\n\u64a4\u9500\u6682\u5b58\u533a\u64cd\u4f5c&nbsp;\ngit reset .<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>git\u5206\u652f\u64cd\u4f5c\n\u7c7b\u4f3c\u4e8e\u526f\u672c\u7684\u4e1c\u897f\uff0c\u4f46\u662f\u4e0d\u662f\n\n\u4ec5\u5728\u5de5\u4f5c\u533a\u8fdb\u884c\u4fee\u6539\u540e\uff0c\u5207\u6362\u5230\u5176\u4ed6\u5206\u652f\uff0c\u5728\u8fd4\u56de\u8be5\u5206\u652f\u540e\u53ef\u80fd\u4f1a\u51fa\u73b0\u5f02\u5e38\uff0c\u5efa\u8bae\u4fee\u6539\u540e\u53ca\u65f6\u4e0a\u4f20\u6682\u5b58\u533a\u3001\u672c\u5730\u5e93\n\n\u67e5\u770b\u5206\u652f\ngit branch -v\n\u521b\u5efa\u5206\u652f\ngit branch \u5206\u652f\u540d\u5b57\n\u5207\u6362\u5206\u652f\ngit checkout \u5206\u652f\u540d\u5b57\n\n\u5408\u5e76\u5206\u652f\ngit merge \u8981\u5408\u5e76\u7684\u5206\u652f\u540d\u5b57\n\u51b2\u7a81\u7684\u5408\u5e76\u5206\u652f\n\u5373\u4ee3\u7801\u6709\u4e24\u5957\u4e0d\u540c\u7684\u5206\u652f<img loading=\"lazy\" decoding=\"async\" height=\"15\" width=\"15\" src=\"blob:https:\/\/eve2333.top\/4d5f0a4a-729f-4369-a812-8abcbece7b88\"><\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"189\" src=\"https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729738255-1de28f6d1644e6849fd1bfb1d63a2060-1024x189.png\" alt=\"\" class=\"wp-image-399\" srcset=\"https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729738255-1de28f6d1644e6849fd1bfb1d63a2060-1024x189.png 1024w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729738255-1de28f6d1644e6849fd1bfb1d63a2060-300x55.png 300w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729738255-1de28f6d1644e6849fd1bfb1d63a2060-768x142.png 768w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729738255-1de28f6d1644e6849fd1bfb1d63a2060.png 1098w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>&nbsp;\u6b64\u65f6\u5408\u5e76\u5931\u8d25\u4e86\uff0c\u9700\u8981\u624b\u52a8\u5408\u5e76\u4ee3\u7801<\/p>\n\n\n\n<p><strong>master \u548c fix-hot \u5728\u540c\u4e00\u4e2a\u7248\u672c\u7684\u57fa\u7840\u4e0a\u90fd\u8fdb\u884c\u4e86\u4fee\u6539\uff0cmerge\u5c31\u662f\u65b0\u7684\u8986\u76d6\u65e7\u7684\uff0c\u6b64\u65f6\u76f8\u5bf9\u57fa\u7840\u7248\u672c\u90fd\u662f\u65b0\u7684\uff0cgit\u4e0d\u77e5\u9053\u54ea\u4e2a\u662f\u65b0\uff0c\u54ea\u4e2a\u662f\u65e7<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u5728vim\u4e2d\u624b\u52a8\u8fdb\u884c\u64cd\u4f5c\uff0c\u7136\u540e\u8fdb\u884c\u4e00\u4e0badd\n\u5728\u63d0\u4ea4\u672c\u5730\u5e93\u4e2d\uff0c\u5c06\u8981\ngit commmit -m \"merge text\"\n\u4e0d\u8981\u52a0\u540d\u5b57\uff01\/\n\u603b\u7ed3\uff1a\u5408\u5e76\u4e0d\u51b2\u7a81\u662f\u56e0\u4e3a\uff0chotfix\u590d\u5236\u4e86master\u540emaster\u6ca1\u6709\u518d\u6b21\u4fee\u6539\uff0c\u6240\u4ee5\u5408\u5e76\u65f6\u76f4\u63a5\u8986\u76d6\u3002\u800c\u51b2\u7a81\u662fhotfix\u590d\u5236\u540e\uff0cmaster\u548chotfix\u90fd\u4fee\u6539\u4e86\uff0c\u6240\u4ee5\u51b2\u7a81<\/code><\/pre>\n\n\n\n<p><strong>\u56e2\u961f\u5185\u534f\u4f5c<\/strong>\u548c<strong>\u8de8\u56e2\u961f\u534f\u4f5c<\/strong><\/p>\n\n\n\n<p>\u9080\u8bf7\u52a0\u5165\u56e2\u961f<\/p>\n\n\n\n<p>setting -&gt;Manage access -&gt;invite collaborotor<\/p>\n\n\n\n<p>\u628a\u9080\u8bf7\u51fd\u5bc6\u94a5\u590d\u5236\u4e0b\u6765\uff0c\u53d1\u7ed9B<\/p>\n\n\n\n<p>B\u5728\u6d4f\u89c8\u5668\u91cc\u6253\u5f00\u8be5\u7f51\u7ad9\uff0c\u6309\u7167\u63d0\u793a\u64cd\u4f5c\u5373\u53ef<\/p>\n\n\n\n<p>\u5176\u4ed6\u4eba\u6253\u5f00\u4f60\u7684github\u5e93\uff0c\u53ef\u4ee5\u5728\u7ebf\u4fee\u6539\u4ee3\u7801\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">github\u7684\u4f7f\u7528<\/h2>\n\n\n\n<p>\u8fdc\u7a0b\u5e93\u7684\u540d\u5b57\u4e00\u822c\u548c\u672c\u5730\u7684\u662f\u4e00\u6837\u7684<\/p>\n\n\n\n<p>\u4ed6\u4eba\u5bf9\u4e8egithub\u7684\u8fdc\u7a0b\u5e93\uff0c\u70b9\u51fbfork\uff0c\u64cd\u4f5c\u8fdb\u884cpull request<\/p>\n\n\n\n<p>\u672c\u4eba\u5c31\u4f1a\u6536\u5230&nbsp;pull request\uff0c\u5ba1\u6838\u540e\u5373\u53efmerge&nbsp;pull request<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git remote -v\n\u67e5\u770b\u5f53\u524d\u6240\u6709\u8fdc\u7a0b\u5730\u5740\u522b\u540d\n\ngit remote add git-demo URL\n\u6dfb\u52a0\u5730\u5740\u522b\u540d\n\ngit push \u522b\u540d \u5206\u652f\u540d\n\u63a8\u9001\u6587\u4ef6\u5411github\u670d\u52a1\u5668<\/code><\/pre>\n\n\n\n<p>\u73b0\u5728github\u8981\u7528ssh\u5173\u8054\u4e0a\u7ec8\u7aef\u7136\u540e\u7528\u4ee4\u724c\u767b\u9646\u5c31\u53ef\u4ee5push\u4e0a\u53bb\u4e86\u3002<\/p>\n\n\n\n<p>\u539f\u56e0\u5982\u4e0b\uff1a\u5982\u679cssl\u8bc1\u4e66\u672a\u7ecf\u8fc7\u673a\u6784\u8ba4\u8bc1\u3002\u4f1a\u8ba4\u4e3a\u672a\u77e5\u7684\u6ca1\u6709\u7b7e\u7f72\u8fc7\u7684\u8bc1\u4e66\u610f\u5473\u7740\u53ef\u80fd\u5b58\u5728\u5f88\u5927\u7684\u98ce\u9669\u3002<\/p>\n\n\n\n<p>443\u7aef\u53e3<\/p>\n\n\n\n<p><a href=\"https:\/\/blog.csdn.net\/kuilaurence\/article\/details\/135909974\" target=\"_blank\"  rel=\"nofollow\" >\u89e3\u51b3ssh: connect to host github.com port 22: Connection timed out_ssh:connect to host port 22:connection timed out-CSDN\u535a\u5ba2<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/blog.csdn.net\/baidulixueqin\/article\/details\/117962327\" target=\"_blank\"  rel=\"nofollow\" >Vim\/Vi\u4e2d\u4fdd\u5b58\u6587\u4ef6\u5e76\u9000\u51fa\u7f16\u8f91\u5668_\u4f7f\u7528vi\/vim\u7f16\u8f91\u5668\u67e5\u770b\u5f53\u524d\u76ee\u5f55\u4e0b\u5df2\u5b58\u5728\u6587\u4ef6oldfile,\u7136\u540e\u4fdd\u5b58\u9000\u51favi\/vim\u7f16\u8f91\u5668;-CSDN\u535a\u5ba2<\/a><\/p>\n\n\n\n<p><s>2021\u5e748\u670813\u65e5\u8d77\uff0cGithub\u4e0d\u518d\u652f\u6301\u4f7f\u7528\u5bc6\u7801push\uff01\u8001\u5e08\u8fd9\u4e2apush\u65b9\u6cd5\u8fc7\u65f6\u4e86<\/s><\/p>\n\n\n\n<p><s>\u7b2c\u4e00\u6b21push \u9700\u8981\u52a0 -u &nbsp;\u5b8c\u6574\u547d\u4ee4 git push -u \u522b\u540d master ,\u81ea\u5df1git \u767b\u5f55\u7684\u6d4f\u89c8\u5668\u4e00\u5b9a\u8981\u548c\u8ba4\u8bc1\u6253\u5f00\u7684\u6d4f\u89c8\u5668\u662f\u540c\u4e00\u4e2a\uff0c\u4e00\u76f4\u8d85\u65f6\uff0c\u8fde\u63a5\u624b\u673a\u70ed\u70b9\uff0c\u518d\u4e0a\u4f20 <\/s>\u770b\u770b\u5c31\u597d<\/p>\n\n\n\n<p>\u8bb0\u5f97\u5220\u9664\u51ed\u636e\u7ba1\u7406\u5668\u7684\u51ed\u636e<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u62c9\u53d6\u8fdc\u7a0bgithub\u5e93\ngit pull git-demo master\n\n\u4efb\u610f\u62c9\u53d6\u4e00\u4e2a\u5e93\ngit clone URL\n\/\/\u514b\u9686\u662f\u672c\u5730\u6ca1\u6709\u65f6\u7528\u7684\uff0c\u62c9\u53d6\u662f\u672c\u5730\u5df2\u7ecf\u6709\u4e86\u7684\u65f6\u5019\u7528\u7684\/\/\nclone\u4f1a\u5e72\u4e09\u4ef6\u4e8b\uff0c1\uff0c\u62c9\u53d6\u4ee3\u78012.\u521d\u59cb\u5316\u672c\u5730\u5e933.\u521b\u5efa\u522b\u540d<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">ssh\u7684\u4f7f\u7528<\/h2>\n\n\n\n<p>\u5728C\u76d8\u91cc\u9762\u7528\u6237\u4e0b\u6709.ssh\u7684\u6587\u4ef6\u5939,\u4f7f\u7528\u4ee5\u4e0b\u7684\u547d\u4ee4\u751f\u6210<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh-keygen -t rsa -C XXXX@163.com\n\/\/\u7136\u540e\u6572\u4e09\u6b21\u56de\u8f66<\/code><\/pre>\n\n\n\n<p>\u52a0\u5bc6\u7b97\u6cd5\u53ef\u4ee5\u4f7f\u7528 Ed25519\uff0c\u4e00\u822c\u53ea\u8981\u4e0d\u662f\u592a\u65e7\u7684\u673a\u5668\u90fd\u652f\u6301\uff0c\u6bd4rsa\u597d<\/p>\n\n\n\n<p>\u6253\u5f00rsa.pub\u5c31\u662f\u4f60\u7684\u79c1\u94a5<\/p>\n\n\n\n<p>pull\u662f\u62c9\u53d6\uff0c\u9488\u5bf9\u7684\u6211\u5df2\u7ecf\u6709\u672c\u5730\u4ed3\u5e93\uff0c\u4f46\u662f\u548c\u8fdc\u7a0b\u5e93\u6570\u636e\u4e0d\u540c\u6b65\u7684\u60c5\u51b5\uff0c\u514b\u9686\u662f\u8fde\u672c\u5730\u5e93\u90fd\u6ca1\u6709\uff0c\u76f4\u63a5\u4ece\u8fdc\u7a0b\u5e93copy\u4e00\u4efd\u5230\u672c\u5730\u5f53\u4f5c\u672c\u5730\u5e93<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">idea\u7684\u4f7f\u7528<\/h2>\n\n\n\n<p>\u9700\u8981\u5ffd\u7565\u4e00\u4e9b\u6ca1\u6709\u5fc5\u8981\u7684\u4e1c\u897f<\/p>\n\n\n\n<p>\u5728\u7528\u6237\u6587\u4ef6\u5939\u4e0b\uff0c\u65b0\u5efa\u4e00\u4e2agit.ignore\uff0c\u5ffd\u7565\u4ec0\u4e48\u5c31 *.\u4ec0\u4e48<\/p>\n\n\n\n<p>\u4e0b\u9762\u662f\u5bf9IJ\u7684\u6837\u4f8b\u6587\u4ef6<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Compiled class file\n*.class\n\n# Log file\n*.log\n\n# BlueJ files\n*.ctxt\n\n# Mobile Tools for Java (J2ME) \n.mtj.tmp\/\n\n# Package Files #\n*.jar\nI\n*.war\n*.nar\n*.ear\n*.zip\n*.tar.gz\n*.rar\n\n# virtual machine crash logs, see http:\/\/www.java.com\/en\/download\/help\/error_hotspot.xml       \t\ths_err_pid*\n\n.classpath\n.project \n.settings target \n.idea\n*.iml <\/code><\/pre>\n\n\n\n<p>\u5bf9\u4e8egitconfig\u6587\u4ef6\uff0c\u53ef\u4ee5\u53d8\u6210<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;user]\n    name = Layne\n    email=Layne@atguigu.com \n&#91;core]\n    excludesfile = C:\/Users\/asus\/git.ignore \/\/windows\u662f\u53cd\u659c\u7ebf <img loading=\"lazy\" decoding=\"async\" height=\"15\" width=\"15\" src=\"blob:https:\/\/eve2333.top\/8bff5ad0-4498-4a45-9589-90a922828de7\"><\/code><\/pre>\n\n\n\n<p>\u5728\u4f60\u7684idea\u91cc\u9762\uff0csetting-&gt; version control -&gt;\u9009\u62e9\u81ea\u5df1\u6240\u5728\u6587\u4ef6\u91cc\u9762\u7684git.exe<\/p>\n\n\n\n<p>VCS\u91cc\u9762create git resposbility<\/p>\n\n\n\n<p>\u53f3\u952e\u6587\u4ef6\uff0cgit---&gt;add<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">idea\u7684\u5207\u6362\u7248\u672c<\/h6>\n\n\n\n<p>\u8fd9\u91cc\u4e0d\u9700\u8981add\u4e86\u5427\uff0cidea\u8c8c\u4f3c\u6682\u5b58\u533a\u6982\u5ff5\u5f88\u5f31\uff0c\u8ffd\u8e2a\u540e\u9ed8\u8ba4\u5c31\u662fcommit -a\u7684<\/p>\n\n\n\n<p>\u53ef\u4ee5\u70b9\u51fb\u90a3\u4e2a\u53cc\u5411\u7bad\u5934\uff08Show Diff\uff09\u5bf9\u6bd4\u663e\u793a\u4fee\u6539\u7684\u4ee3\u7801<\/p>\n\n\n\n<p>idea\u7684\u4e0b\u89d2\u6709version control -\u300blog\u53ef\u4ee5\u770b\u5230\u7248\u672c\u8fed\u4ee3<\/p>\n\n\n\n<p>\u53f3\u952e\u7248\u672c\uff0c\u70b9\u51fbcheckout\u5373\u53ef<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">idea\u7684\u4f7f\u7528\u5206\u652f<\/h6>\n\n\n\n<p>\u53f3\u952e\u6587\u4ef6---\u300bgit----\u300b----\u300brepository---\u300bBranches-----\u300bnew branch<\/p>\n\n\n\n<p>\u6216\u8005idea\u4e0b\u89d2\u6709 git\uff1amaster\uff0c\u70b9\u51fb\u5373\u53ef<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">idea\u5408\u5e76\u5206\u652f<\/h6>\n\n\n\n<p>marge into current<\/p>\n\n\n\n<p>\u6709\u51b2\u7a81\u7684\u65f6\u5019\uff1a\u4f1a\u51fa\u73b0merge\uff0c\u624b\u52a8\u66f4\u6539\u4e00\u4e0b<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">idea\u662f\u53ef\u4ee5\u94fe\u63a5github gitee\u7684\uff0c\u4f46\u662f\u61d2\u5f97\u7528<\/h6>\n\n\n\n<h1 class=\"wp-block-heading\">\u603b\u7ed3<\/h1>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>1.\u8be6\u7ec6\u5185\u5bb9\u770b\u5b66\u4e60\u7b14\u8bb0<br>2.\u8fd9\u91cc\u53ea\u6574\u7406\u4e00\u4e9b\u547d\u4ee4\u548c\u573a\u666f<br>3.\u5176\u5b9e\u8fd8\u6709\u5f88\u591a\u547d\u4ee4\uff0c\u4e0d\u8fc7\u6709\u4e00\u4e9b\u90fd\u53ef\u4ee5\u7531\u4e0b\u9762\u57fa\u7840\u7684\u547d\u4ee4\u5f97\u5230\u3002\u4f8b\u5982\uff1a\u8981\u5c06\u5185\u5bb9\u4ece<code>HEAD<\/code>\u6062\u590d\u5230<code>\u5de5\u4f5c\u533a<\/code>\uff0c\u53ea\u9700\u8981\u5c06\u5185\u5bb9\u4ece<code>HEAD<\/code>-><code>\u6682\u5b58\u533a<\/code>-><code>\u5de5\u4f5c\u533a<\/code>\u3002<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\"><a><\/a><a><\/a>\u672c\u5730\u5e93\u76f8\u5173\u547d\u4ee4<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>git init # \u521d\u59cb\u5316Git\u7248\u672c\u5e93\ngit clone # \u901a\u8fc7\u514b\u9686\u5f00\u6e90\u4ee3\u7801\u5230\u672c\u5730\u8fdb\u884c\u7248\u672c\u7ba1\u7406\n----------------------------------------\ngit add &lt;filename> \u6216 git add . # \u63d0\u4ea4\u6587\u4ef6\u5230\u6682\u5b58\u533a\ngit commit -m \"message\" # \u6587\u4ef6\u4ece\u6682\u5b58\u533a\u63d0\u4ea4\u5230\u7248\u672c\u5e93\uff0c\u5176\u4e2d\"message\"\u662f\u5bf9\u5e94\u63d0\u4ea4\u7684\u6ce8\u91ca\n----------------------------------------\ngit status # \u67e5\u8be2\u5de5\u4f5c\u533a\u72b6\u6001\ngit diff &lt;filename> # \u67e5\u770b\u7248\u672c\u5e93\u7684\u5185\u5bb9\u548c\u5f53\u524d\u6587\u4ef6\u5185\u5bb9\u7684\u533a\u522b\n----------------------------------------\ngit log # \u663e\u793a\u6700\u8fd1\u5230\u6700\u8fdc\u7684\u63d0\u4ea4\u65e5\u5fd7\uff0c\u80fd\u5b9a\u4f4d\u8fc7\u53bb\u7684\u7248\u672c\ngit log --pretty-oneline # \u7b80\u5316git log\u7684\u8f93\u51fa\u7ed3\u679c\u4e3a\u4e00\u884c\ngit reflog # \u67e5\u770b\u547d\u4ee4\u65e5\u5fd7\uff0c\u80fd\u5b9a\u4f4d\u672a\u6765\u7684\u7248\u672c\ngit reset --hard HEAD^ # \u56de\u9000\u5230\u4e0a\u4e2a\u7248\u672c\ngit reset --hard commit_id # \u56de\u5230\u6307\u5b9a\"commit_id\"\u7684\u7248\u672c\uff0ccommit_id\u4e0d\u9700\u8981\u5b8c\u6574\n----------------------------------------\ngit restore &lt;filename> # \u5c06\u5185\u5bb9\u4ece`\u6682\u5b58\u533a`\u6062\u590d\u5230`\u5de5\u4f5c\u533a`(\u7ed3\u679c\u7b49\u4ef7\u4e8e\"\u5de5\u4f5c\u533a\u6587\u4ef6\u4fee\u6539\u64a4\u9500\")\ngit restore --staged &lt;filename> # \u5c06\u5185\u5bb9\u4ece`HEAD`\u6062\u590d\u5230`\u6682\u5b58\u533a`(\u7ed3\u679c\u7b49\u4ef7\u4e8e\"\u6682\u5b58\u533a\u6587\u4ef6\u4fee\u6539\u64a4\u9500\")\ngit restore --soucre=&lt;commit_id\/HEAD> &lt;filename> # \u5c06`\u6307\u5b9a\u6765\u6e90`\u7684\u5185\u5bb9\u6062\u590d\u5230`\u5de5\u4f5c\u533a`\n----------------------------------------\ngit rm --cached &lt;filename> # \u4ece\u6682\u5b58\u533a\u5220\u9664\u6587\u4ef6\ngit rm &lt;filename> # \u4ece\u6682\u5b58\u533a\u548c\u5de5\u4f5c\u533a\u4e2d\u90fd\u5220\u9664\u6587\u4ef6(\u4e24\u4e2a\u533a\u90fd\u6709\u8be5\u6587\u4ef6\uff0c\u5426\u5219\u62a5\u9519)=rm+git add,\u5982\u679c\u5e26-f\u53c2\u6570\u53ef\u4ee5\u5b9e\u73b0\u5f3a\u5236\u5220\u9664\n----------------------------------------\ngit clean -n # \u9884\u89c8\"\u672a\u88abGit\u8ddf\u8e2a\u7684\u6587\u4ef6\"\uff0c\u5b83\u4eec\u53ef\u88ab\u5220\u9664\ngit clean -f # \u5220\u9664\u672a\u88abGit\u8ddf\u8e2a\u7684\u6587\u4ef6\ngit clean -i # \u4ea4\u4e92\u5f0f\u5220\u9664\u672a\u88abGit\u8ddf\u8e2a\u7684\u6587\u4ef6\n----------------------------------------\ngit stash # \u4fdd\u5b58\"\u5de5\u4f5c\u73b0\u573a\"\ngit stash list # \u67e5\u770b\u4fdd\u5b58\u7684\u5de5\u4f5c\u73b0\u573a\ngit stash apply # \u6062\u590d\u5de5\u4f5c\u73b0\u573a\uff0c\u4f46\u662fstash\u5185\u5bb9\u4e0d\u5220\u9664\uff0c\u5220\u9664\u9700\u8981 git stash drop\ngit stash apply stash@{0} # \u6062\u590d\u7279\u5b9astash\ngit stash pop # \u6062\u590d\u5de5\u4f5c\u73b0\u573a\u7684\u540c\u65f6\u5220\u9664stash\u5185\u5bb9\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u8fdc\u7a0b\u5e93\u76f8\u5173\u547d\u4ee4<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>git remote -v # \u67e5\u770b\u8fdc\u7a0b\u5e93\u7684\u4fe1\u606f\ngit remote rm origin # \u89e3\u9664\u4e0e\u8fdc\u7a0b\u5e93origin\u7684\u5173\u8054\ngit remote add origin git@github.com:\u540d\u79f0\/\u4ed3\u5e93.git # \u5173\u8054\u8fdc\u7a0b\u4ed3\u5e93\uff0c\u5e76\u8d77\u522b\u540d\u4e3aorigin\ngit push -u origin main # -u\u8868\u793amain\u5206\u652f\u548corigin\/main\u5206\u652f\u5173\u8054\u8d77\u6765\uff0c\u65b9\u4fbf\u540e\u7eed\u63a8\u9001\u548c\u62c9\u53d6\u7b80\u5316\u547d\u4ee4\ngit push origin main # \u5c06\u672c\u5730main\u5206\u652f\u5185\u5bb9\u63a8\u5230\u8fdc\u7a0b\u5e93origin\ngit pull --set-upstream-to=origin\/dev dev # \u5c06\u672c\u5730dev\u5206\u652f\u4e0e\u8fdc\u7a0b\u5e93\u7684dev\u5206\u652f\u5173\u8054\ngit pull # \u62c9\u53d6\u8fdc\u7a0b\u5e93\u5bf9\u5e94\u5206\u652f\u7684\u5185\u5bb9\n----------------------------------------\ngit clone git@github.com:\u540d\u79f0\/\u4ed3\u5e93.git # \u514b\u9686\u8fdc\u7a0b\u5e93<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u5206\u652f\u76f8\u5173\u547d\u4ee4<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>git branch # \u67e5\u770b\u672c\u5730\u5206\u652f\ngit switch -c &lt;\u5206\u652fa> # \u521b\u5efa\u5e76\u5207\u6362\u5206\u652f=git branch &lt;\u5206\u652fa> + git switch &lt;\u5206\u652fa>\ngit branch -d &lt;\u5206\u652fa> # \u5220\u9664\u5206\u652fa\ngit merge &lt;\u5206\u652fa> # \u5c06&lt;\u5206\u652fa>\u5408\u5e76\u5230\u5f53\u524d\u5206\u652f\u4e0a\ngit merge --no-ff -m \"xxx\" &lt;\u5206\u652fa> # --no-ff\u8868\u793a\"\u7981\u7528\u5feb\u901f\u5408\u5e76\"\ngit log --graph --pretty=oneline --abbrev-commit # \u67e5\u770b\u5206\u652f\u5408\u5e76\u60c5\u51b5<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u6807\u7b7e\u76f8\u5173\u6307\u4ee4<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>git tag v1.0 commit_id # \u4e3a\u5bf9\u5e94commit(\u7701\u7565\u5219\u8868\u793a\u5f53\u524d\u63d0\u4ea4)\u6253\u4e0av1.0\u6807\u7b7e\uff0c\u53ef\u4ee5\u8865\u5145-m \"\"\u6765\u6307\u5b9a\u8bf4\u660e\u6587\u5b57\ngit tag # \u67e5\u770b\u5df2\u6253\u7684\u6807\u7b7e\ngit show v1.0 # \u67e5\u770bv1.0\u6807\u7b7e\u7684\u8be6\u7ec6\u4fe1\u606f\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Git \u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u5206\u5e03\u5f0f\u7248\u672c\u63a7\u5236\u7cfb\u7edf\uff0c\u7528\u4e8e\u654f\u6377\u9ad8\u6548\u5730\u5904\u7406\u4efb\u4f55\u6216\u5c0f\u6216\u5927\u7684\u9879\u76ee\u3002 Git \u662f Linus Torvalds \u4e3a\u4e86\u5e2e\u52a9 &#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":[2],"tags":[13],"class_list":["post-398","post","type-post","status-publish","format-standard","hentry","category-2","tag-13"],"_links":{"self":[{"href":"https:\/\/eve2333.top\/index.php?rest_route=\/wp\/v2\/posts\/398","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eve2333.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eve2333.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eve2333.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/eve2333.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=398"}],"version-history":[{"count":0,"href":"https:\/\/eve2333.top\/index.php?rest_route=\/wp\/v2\/posts\/398\/revisions"}],"wp:attachment":[{"href":"https:\/\/eve2333.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=398"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eve2333.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=398"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eve2333.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=398"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}