{"id":457,"date":"2024-08-30T00:19:07","date_gmt":"2024-08-29T16:19:07","guid":{"rendered":"https:\/\/awamyy.top\/?p=457"},"modified":"2024-09-12T12:50:44","modified_gmt":"2024-09-12T04:50:44","slug":"test","status":"publish","type":"post","link":"https:\/\/awamyy.top\/?p=457","title":{"rendered":"Git\u5e38\u7528\u547d\u4ee4"},"content":{"rendered":"\n<p>0.\u5bfc\u8a00\uff0cGit\u4f5c\u4e3a\u4e00\u4e2a\u7248\u672c\u63a7\u5236\u5de5\u5177\uff0c\u7ed9\u6587\u4ef6\u5212\u5206\u4e3a\u4e86\u4e09\u4e2a\u533a\uff1a\u201c\u5de5\u4f5c\u533a\u201d(\u672c\u5730\u76ee\u5f55\u4e2d\u7684\u6587\u4ef6)\u3001\u201c\u6682\u5b58\u533a\u201d(\u51c6\u5907\u63d0\u4ea4\u5230\u672c\u5730\u4ed3\u5e93\u7684\u7f13\u5b58\u533a\u57df)\u3001\u201c\u672c\u5730\u4ed3\u5e93\u201d(\u9700\u8981\u81ea\u5df1\u521b\u5efa\uff0c\u7528\u4e8e\u5b58\u50a8\u4ee3\u7801\u548c\u7248\u672c\u4fe1\u606f)\u3002\u57fa\u672c\u7684\u6d41\u7a0b\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\" style=\"font-size:14px\"><code>\u5de5\u4f5c\u533a <strong>-&#91;git add]-&gt;<\/strong> \u6682\u5b58\u533a <strong>-&#91;git commit]-&gt;<\/strong> \u672c\u5730\u4ed3\u5e93<\/code><\/pre>\n\n\n\n<p style=\"font-size:20px\"><strong>1.\u914d\u7f6e<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\" style=\"font-size:14px\"><code>git --version &#91;\u67e5\u770b\u5f53\u524d\u7248\u672c]\ngit config --global user.name \"yourname\" \/\/\u4fee\u6539\u63d0\u4ea4\u8005\u540d\u79f0\uff0c--global\u53c2\u6570\u4e3a\u5168\u5c40\u4fee\u6539\ngit config --global user.email \"youremail\" \/\/\u4fee\u6539\u63d0\u4ea4\u8005\u90ae\u7bb1<\/code><\/pre>\n\n\n\n<p style=\"font-size:20px\"><strong>2.\u521b\u5efa\u4ee3\u7801\u4ed3\u5e93<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\" style=\"font-size:14px\"><code>git init \/\/\u521b\u5efa\u672c\u5730\u4ed3\u5e93\ngit clone url \/\/\u514b\u9686\u8fdc\u7a0b\u4ed3\u5e93\u5230\u672c\u5730<\/code><\/pre>\n\n\n\n<p style=\"font-size:20px\"><strong>3.\u63d0\u4ea4\u548c\u6dfb\u52a0\u6587\u4ef6<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\" style=\"font-size:14px\"><code>git status \/\/\u67e5\u770b\u4ed3\u5e93\u72b6\u6001\uff0c\u5982\uff1a\u67e5\u770b\u5f53\u524d\u4ed3\u5e93\u5206\u652f\u3001\u4ed3\u5e93\u6587\u4ef6\u72b6\u6001\ngit add . \/\/\u6dfb\u52a0\u6587\u4ef6\u5230\u6682\u5b58\u533a\uff0c. \u4ee3\u8868\u5f53\u524d\u76ee\u5f55\u7684\u6587\u4ef6\uff0c\u591a\u4e2a\u6587\u4ef6\u7528\u7a7a\u683c\u5206\u9694\uff0c\u4e5f\u53ef\u4f7f\u7528\u901a\u914d\u7b26\u6216\/src\ngit commit -m \"\u63cf\u8ff0\u4fe1\u606f\" \/\/\u63d0\u4ea4\u6682\u5b58\u533a\u7684\u6587\u4ef6\u5230\u672c\u5730\u4ed3\u5e93<\/code><\/pre>\n\n\n\n<p style=\"font-size:20px\"><strong>4.\u67e5\u770b\u8bb0\u5f55\u548c\u6587\u4ef6<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\" style=\"font-size:14px\"><code>git log --oneline \/\/--oneline\u53c2\u6570\u4e3a\u663e\u793a\u7b80\u6d01\u7248\u7684log\ngit ls-files \/\/\u67e5\u770b\u6682\u5b58\u533a\u6587\u4ef6\ngit log --graph --oneline --decorate --all \/\/\u67e5\u770b\u5206\u652f\u56fe<\/code><\/pre>\n\n\n\n<p style=\"font-size:20px\"><strong>5.\u56de\u9000\u672c\u5730\u4ed3\u5e93\u7248\u672c<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\" style=\"font-size:14px\"><code>git reset --soft &lt;\u56de\u9000\u5230\u7684\u7248\u672cID&gt; \/\/\u4fdd\u7559\u5de5\u4f5c\u533a\u548c\u6682\u5b58\u533a\ngit reset --hard &lt;\u56de\u9000\u5230\u7684\u7248\u672cID&gt; \/\/\u5de5\u4f5c\u533a\u548c\u6682\u5b58\u533a\u90fd\u4e0d\u4fdd\u7559\ngit reset --mixed &lt;\u56de\u9000\u5230\u7684\u7248\u672cID&gt; \/\/\u4fdd\u7559\u5de5\u4f5c\u533a\uff0c\u4e0d\u4fdd\u7559\u6682\u5b58\u533a (\u9ed8\u8ba4\u6a21\u5f0f)<\/code><\/pre>\n\n\n\n<p style=\"font-size:20px\"><strong>6.\u67e5\u770b\u5de5\u4f5c\u533a\u3001\u6682\u5b58\u533a\u3001\u672c\u5730\u4ed3\u5e93\u7684\u5dee\u5f02<\/strong><\/p>\n\n\n\n<p><strong>  <\/strong>\u6982\u5ff5\uff1aHEAD\u6307\u5411\u7684\u662f\u5f53\u524d\u5206\u652f\u7684\u6700\u65b0\u4e00\u6b21\u63d0\u4ea4\u7684\u7248\u672c<\/p>\n\n\n\n<pre class=\"wp-block-code\" style=\"font-size:14px\"><code>git diff \/\/\u9ed8\u8ba4\uff0c\u67e5\u770b\u5f53\u524d\u5de5\u4f5c\u533a\u548c\u6682\u5b58\u533a\u7684\u5dee\u5f02\ngit diff HEAD \/\/\u67e5\u770b\u5f53\u524d\u5de5\u4f5c\u533a\u4e0eHEAD\u4e4b\u524d\u7684\u5dee\u5f02\ngit diff &lt;\u7248\u672cID&gt; &lt;\u7248\u672cID&gt; \/\/\u67e5\u770b\u6307\u5b9a\u4e24\u4e2a\u7248\u672c\u4e4b\u95f4\u7684\u5dee\u5f02\ngit diff HEAD~ HEAD \/\/\u67e5\u770b\u6700\u65b0\u7248\u672c\u548c\u524d\u4e00\u4e2a\u7248\u672c\u4e4b\u95f4\u7684\u5dee\u5f02\uff0c~\u8868\u793a\u524d\u4e00\u4e2a\u7248\u672c\uff0c~\u540e\u53ef\u586b\u6570\u5b57\uff0c\u5982\uff1a~x\u4e3aHEAD\u524d\u7684\u7b2cx\u4e2a\u7248\u672c\ngit diff --cached \/\/\u67e5\u770bHEAD\u4e0e\u6682\u5b58\u533a\u5185\u6587\u4ef6\u7684\u6539\u52a8\ngit diff &lt;\u7248\u672cID&gt; &lt;\u7248\u672cID&gt; &lt;\u6587\u4ef6\u540d&gt; \/\/\u67e5\u770b\u6307\u5b9a\u4e24\u4e2a\u7248\u672c\u4e2d\u6307\u5b9a\u6587\u4ef6\u7684\u5dee\u5f02\ngit diff &lt;\u5206\u652f\u540d&gt; &lt;\u5206\u652f\u540d&gt; \/\/\u67e5\u770b\u5206\u652f\u4e4b\u95f4\u7684\u5dee\u5f02<\/code><\/pre>\n\n\n\n<p style=\"font-size:20px\"><strong>7.\u5220\u9664\u6587\u4ef6<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\" style=\"font-size:14px\"><code>git rm &lt;\u6587\u4ef6\u540d&gt; \/\/\u4ece\u5de5\u4f5c\u533a\u548c\u6682\u5b58\u533a\u5220\u9664\ngit rm --cached &lt;\u6587\u4ef6\u540d&gt; \/\/\u4ece\u6682\u5b58\u533a\u4e2d\u5220\u9664\u6587\u4ef6\ngit rm -r * \/\/\u9012\u5f52\u5220\u9664\u76ee\u5f55\u4e0b\u6240\u6709\u5b50\u76ee\u5f55\u548c\u6587\u4ef6\uff0c\u614e\u7528<\/code><\/pre>\n\n\n\n<p> <strong> <\/strong>\u6ce8\u610f\uff1a\u5220\u9664\u6587\u4ef6\u540e\u8981\u6267\u884c\u4e00\u6b21commit\u547d\u4ee4\u624d\u80fd\u540c\u6b65\u5220\u9664\u64cd\u4f5c\u5230\u672c\u5730\u4ed3\u5e93<\/p>\n\n\n\n<p style=\"font-size:20px\"><strong>8.\u5173\u8054\u3001\u514b\u9686\u3001\u62c9\u53d6\u3001\u63a8\u9001<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git remote add origin &lt;\u8fdc\u7a0b\u4ed3\u5e93\u94fe\u63a5&gt; \/\/\u672c\u5730\u4ed3\u5e93\u5173\u8054\u8fdc\u7a0b\u4ed3\u5e93\ngit pull &lt;\u8fdc\u7a0b\u4ed3\u5e93\u540d&gt; &lt;\u8fdc\u7a0b\u5206\u652f\u540d&gt; \/\/\u62c9\u53d6\u8fdc\u7a0b\u4ed3\u5e93\u6307\u5b9a\u5206\u652f\u7684\u5185\u5bb9\uff0c&lt;\u8fdc\u7a0b\u4ed3\u5e93\u540d&gt;\u522b\u540dorigin\ngit push -u &lt;\u8fdc\u7a0b\u4ed3\u5e93\u540d&gt; &lt;\u8fdc\u7a0b\u5206\u652f\u540d&gt; \/\/\u63a8\u9001\u5185\u5bb9\u5230\u8fdc\u7a0b\u6307\u5b9a\u5206\u652f\uff0c&lt;\u8fdc\u7a0b\u4ed3\u5e93\u540d&gt;\u522b\u540dorigin\uff0c-u\u53c2\u6570\u9996\u6b21\u63a8\u9001\u65f6\u53ef\u7528\u6765\u8bbe\u7f6e\u5206\u652f\u7684\u8ddf\u8e2a\u5173\u7cfb\uff0c\u4f7f\u5f97\u540e\u7eed\u65e0\u9700\u6bcf\u6b21\u90fd\u586b\u5199&lt;\u8fdc\u7a0b\u4ed3\u5e93\u540d&gt;\u548c&lt;\u8fdc\u7a0b\u5206\u652f\u540d&gt;<\/code><\/pre>\n\n\n\n<p style=\"font-size:20px\"><strong>9.\u5206\u652f\u64cd\u4f5c<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git branch &lt;\u5206\u652f\u540d&gt; \/\/\u521b\u5efa\u5206\u652f\ngit branch -d||-D &lt;\u5206\u652f\u540d&gt; \/\/\u5220\u9664\u5206\u652f\uff0c-d\u662f\u5220\u9664\u5df2\u7ecf\u5408\u5e76\u8fc7\u7684\u5206\u652f\uff0c-D\u662f\u5f3a\u5236\u5220\u9664\u5206\u652f\ngit switch &lt;\u5206\u652f\u540d&gt; \/\/\u5207\u6362\u5206\u652f\ngit checkout &lt;\u5206\u652f\u540d||\u6587\u4ef6\u540d&gt; \/\/\u5207\u6362\u5230\u67d0\u4e2a\u5206\u652f||\u6062\u590d\u6587\u4ef6\u5230\u4fee\u6539\u524d\u7684\u72b6\u6001\uff0c\u82e5\u5206\u652f\u540d\u548c\u6587\u4ef6\u540d\u76f8\u540c\u5219\u9ed8\u8ba4\u5207\u6362\u5206\u652f\ngit merge &lt;\u5206\u652f\u540d&gt; \/\/\u628a&lt;\u5206\u652f\u540d&gt;\u7684\u5206\u652f\u5185\u5bb9\u5408\u5e76\u5230\u5f53\u524d\u6240\u5728\u5206\u652f<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>0.\u5bfc\u8a00\uff0cGit\u4f5c\u4e3a\u4e00\u4e2a\u7248\u672c\u63a7\u5236\u5de5\u5177\uff0c\u7ed9\u6587\u4ef6\u5212\u5206\u4e3a \u2026<\/p>\n","protected":false},"author":1,"featured_media":470,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[19,1],"tags":[20,22,21],"_links":{"self":[{"href":"https:\/\/awamyy.top\/index.php?rest_route=\/wp\/v2\/posts\/457"}],"collection":[{"href":"https:\/\/awamyy.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/awamyy.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/awamyy.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/awamyy.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=457"}],"version-history":[{"count":67,"href":"https:\/\/awamyy.top\/index.php?rest_route=\/wp\/v2\/posts\/457\/revisions"}],"predecessor-version":[{"id":593,"href":"https:\/\/awamyy.top\/index.php?rest_route=\/wp\/v2\/posts\/457\/revisions\/593"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/awamyy.top\/index.php?rest_route=\/wp\/v2\/media\/470"}],"wp:attachment":[{"href":"https:\/\/awamyy.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=457"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/awamyy.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=457"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/awamyy.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=457"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}