{"id":29,"date":"2021-03-13T11:44:05","date_gmt":"2021-03-13T03:44:05","guid":{"rendered":"http:\/\/daishen.ltd\/?p=29"},"modified":"2021-03-13T11:44:05","modified_gmt":"2021-03-13T03:44:05","slug":"git%e5%91%bd%e4%bb%a4","status":"publish","type":"post","link":"https:\/\/www.daishen.ltd\/?p=29","title":{"rendered":"git\u547d\u4ee4"},"content":{"rendered":"<p><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width initial-scale=1\"><br \/>\n<title>git\u547d\u4ee4<\/title><\/p>\n<h4>Git\u57fa\u7840\u547d\u4ee4<\/h4>\n<pre><code class=\"language-shell\" lang=\"shell\">1.git init \u521d\u59cb\u5316\u4ee3\u7801\u5e93\uff0c\u628a\u4e00\u4e2a\u76ee\u5f55\u521d\u59cb\u5316\u4e3a\u7248\u672c\u4ed3\u5e93\uff08\u53ef\u4ee5\u662f\u7a7a\u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u662f\u5e26\u5185\u5bb9\u7684\u76ee\u5f55\uff09\n\n2.git status \u67e5\u770b\u5f53\u524d\u4ed3\u5e93\u7684\u72b6\u6001\n\n3.git add [file] \u6dfb\u52a0\u6587\u4ef6\u5230\u6682\u5b58\u533a\n\n4.git add * \u6dfb\u52a0\u5f53\u524d\u6240\u6709\u6539\u52a8\u8fc7\u7684\u6587\u4ef6\u5230\u6682\u5b58\u533a\n\n5.git rm --cached \u64a4\u51fa\u5de5\u4f5c\u533a\n\n6.git rm -f \u540c\u65f6\u5220\u9664\u5de5\u4f5c\u76ee\u5f55\u548c\u6682\u5b58\u533a\u7684\u5185\u5bb9\n\n7.git commit -m \"\u4f60\u7684\u63d0\u4ea4\u4fe1\u606f\" \u63d0\u4ea4\u4ee3\u7801\uff0c\u4ece\u7f13\u5b58\u533a\u63d0\u4ea4\u5230\u672c\u5730\u4ed3\u5e93\uff0c-m\u63d0\u4ea4\u4fe1\u606f\n\n8.git mv old-filename new-filename \u76f4\u63a5\u66f4\u6539\u5de5\u4f5c\u533a\u4e0e\u6682\u5b58\u533a\u6587\u4ef6\u540d\u79f0\uff0c\u66f4\u6539\u5b8c\u6210\u76f4\u63a5\u63d0\u4ea4\u5373\u53ef\n\n9.git diff \u9ed8\u8ba4\u6bd4\u5bf9\u5de5\u4f5c\u76ee\u5f55\u548c\u6682\u5b58\u533a\u6709\u4ec0\u4e48\u4e0d\u540c\n\n10.git diff --cached \u6bd4\u5bf9\u6682\u5b58\u533a\u548c\u672c\u5730\u4ed3\u5e93\n\n11.git commit -am \"\u4f60\u7684\u63d0\u4ea4\u4fe1\u606f\"  \u5982\u679c\u67d0\u4e2a\u6587\u4ef6\u5df2\u7ecf\u88ab\u4ed3\u5e93\u7ba1\u7406\uff0c\u5982\u679c\u518d\u6b21\u66f4\u6539\u6b64\u6587\u4ef6\uff0c\u76f4\u63a5\u7528\u6b64\u547d\u4ee4\u63d0\u4ea4\n\n12.git log \u67e5\u770b\u5386\u53f2\u63d0\u4ea4\u8fc7\u7684\u4fe1\u606f git reflog \u67e5\u770b\u5386\u53f2\u6240\u6709\u63d0\u4ea4\u4fe1\u606f\n\n13.git reset --hard 296e997   \u56de\u6eda\u6570\u636e\u5230\u67d0\u4e00\u4e2a\u63d0\u4ea4\n\n14.git log --oneline --decorate \u67e5\u770b\u5f53\u524d\u6307\u9488\u7684\u6307\u5411\n\n15.git branch \u67e5\u770b\u5206\u652f\n\n16.git branch testing \u521b\u5efa \u4e00\u4e2a\u6d4b\u8bd5\u5206\u652f\n\n17.git checkout testing \u5207\u6362\u5230\u6d4b\u8bd5\u5206\u652f\n\n18.git checkout -b testing \u521b\u5efa\u5e76\u5207\u6362\u5230testing\u5206\u652f\n\n19.git tag -a v1.0 -m \"aaa bbb master tesing version v1.0\" # - a\u6307\u5b9a\u6807\u7b7e\u540d\u5b57-m\u6307\u5b9a\u8bf4\u660e\u6587\u5b57\n\n20.git tag -a v2.0 dbead4c -m \"add bbb version v2.0\" #\u6307\u5b9a\u67d0\u6b21\u7684\u63d0\u4ea4\u4e3a\u6807\u7b7e   -d \u5220\u9664\u6807\u7b7e  git tag -d v1.0\n\n21.git show v1.0 #\u67e5\u770bv1. 0\u7684\u4fe1\u606f  git show \u52a0\u6807\u7b7e\u67e5\u770b\n\n22.git reset --hard v2.0 # \u76f4\u63a5\u8fd8\u539f\u6570\u636e\u5230v2. 0\n\n23.git remote add origin https:\/\/github.com\/M-02\/test.git     \u6dfb\u52a0\u8fdc\u7a0b\u4ed3\u5e93,\u540d\u79f0\u4e3aorigin\n\n24.git remote  \u67e5\u770b\u5f53\u524d\u7684\u8fdc\u7a0b\u4ed3\u5e93\u7684\u540d\u79f0\n\n25.git clone \u514b\u9686\u4ee3\u7801\n\n26.git push -u test master \u63a8\u9001\u4ee3\u7801\u5230\u8fdc\u7a0b\u4ed3\u5e93\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4>\u5c0f\u7ed3:\u5982\u4f55\u771f\u6b63\u610f\u4e49\u4e0a\u901a\u8fc7\u7248\u672c\u63a7\u5236\u7cfb\u7edf\u7ba1\u7406\u6587\u4ef6<\/h4>\n<p>1.\u5de5\u4f5c\u76ee\u5f55\u5fc5\u987b\u6709\u4e2a\u4ee3\u7801\u6587\u4ef6<br \/>\n2.\u901a\u8fc7 git add file<br \/>\n\u6dfb\u52a0\u5230\u6682\u5b58\u533a\u57df<br \/>\n3.\u901a\u8fc7 git comnit -m &#8220;\u4f60\u81ea\u5df1\u8f93\u5165\u7684\u4fe1\u606f&#8221;\u201d\u6dfb\u52a0\u5230\u672c\u5730\u4ed3\u5e93<\/p>\n<h4>.git \u9690\u85cf\u6587\u4ef6\u4ecb\u7ecd:<\/h4>\n<p>branches #\u5206\u652f\u76ee\u5f55<br \/>\nconfig #\u5b9a\u4e49\u9879\u76ee\u7279\u6709\u7684\u914d\u7f6e\u9009\u9879<br \/>\ndescription #\u4ec5\u4f9bgit web\u7a0b\u5e8f\u4f7f\u7528<br \/>\nHEAD # \u6307\u793a\u5f53\u524d\u7684\u5206\u652f<br \/>\nhooks # \u5305\u542bgit\u94a9\u5b50\u6587\u4ef6<br \/>\ninfo # \u5305\u542b\u4e00\u4e2a\u5168\u5c40\u6392\u9664\u6587\u4ef6( exclude\u6587\u4ef6)<br \/>\nobjects # \u5b58\u653e\u6240\u6709\u6570\u636e\u5185\u5bb9\uff0c\u6709info\u548cpack\u4e24\u4e2a\u5b50\u6587\u4ef6\u5939<br \/>\nrefs # \u5b58\u653e\u6307\u5411\u6570\u636e(\u5206\u652f)\u7684\u63d0\u4ea4\u5bf9\u8c61\u7684\u6307\u9488<br \/>\nindex # \u4fdd\u5b58\u6682\u5b58\u533a\u4fe1\u606f,\u5728\u6267\u884cgit init\u7684\u65f6\u5019\uff0c\u8fd9\u4e2a\u6587\u4ef6\u8fd8\u6ca1\u6709<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>git\u547d\u4ee4 Git\u57fa\u7840\u547d\u4ee4 1.git init \u521d\u59cb\u5316\u4ee3\u7801\u5e93\uff0c\u628a\u4e00\u4e2a\u76ee\u5f55\u521d\u59cb\u5316\u4e3a\u7248\u672c\u4ed3\u5e93\uff08\u53ef\u4ee5\u662f\u7a7a\u76ee\u5f55\uff0c\u4e5f\u53ef [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-29","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.daishen.ltd\/index.php?rest_route=\/wp\/v2\/posts\/29","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.daishen.ltd\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.daishen.ltd\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.daishen.ltd\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.daishen.ltd\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=29"}],"version-history":[{"count":1,"href":"https:\/\/www.daishen.ltd\/index.php?rest_route=\/wp\/v2\/posts\/29\/revisions"}],"predecessor-version":[{"id":30,"href":"https:\/\/www.daishen.ltd\/index.php?rest_route=\/wp\/v2\/posts\/29\/revisions\/30"}],"wp:attachment":[{"href":"https:\/\/www.daishen.ltd\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=29"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.daishen.ltd\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=29"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.daishen.ltd\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=29"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}