﻿{"id":341,"date":"2017-07-21T17:08:06","date_gmt":"2017-07-21T09:08:06","guid":{"rendered":"http:\/\/www.chenweikang.top\/?p=341"},"modified":"2017-09-19T11:36:54","modified_gmt":"2017-09-19T03:36:54","slug":"git%e5%b8%b8%e7%94%a8%e5%91%bd%e4%bb%a4%e5%a4%a7%e5%85%a8","status":"publish","type":"post","link":"https:\/\/www.chenweikang.top\/?p=341","title":{"rendered":"GIT\u5e38\u7528\u547d\u4ee4\u5927\u5168"},"content":{"rendered":"<blockquote><p>Git\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u5206\u5e03\u5f0f\u7248\u672c\u63a7\u5236\u7cfb\u7edf\uff0c\u53ef\u4ee5\u6709\u6548\u3001\u9ad8\u901f\u7684\u5904\u7406\u4ece\u5f88\u5c0f\u5230\u975e\u5e38\u5927\u7684\u9879\u76ee\u7248\u672c\u7ba1\u7406\u3002 \u00a0Git \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><\/blockquote>\n<div class=\"cnblogs_code\">\n<pre>--------------------------------------GIT\u547d\u4ee4\u5927\u5168-----------------------------------------\r\ngit init                                                  # \u521d\u59cb\u5316\u672c\u5730git\u4ed3\u5e93\uff08\u521b\u5efa\u65b0\u4ed3\u5e93\uff09\r\ngit config --global user.name \"xxx\"                       # \u914d\u7f6e\u7528\u6237\u540d\r\ngit config --global user.email \"xxx@xxx.com\"              # \u914d\u7f6e\u90ae\u4ef6\r\ngit config --global color.ui true                         # git status\u7b49\u547d\u4ee4\u81ea\u52a8\u7740\u8272\r\ngit config --global color.status auto\r\ngit config --global color.diff auto\r\ngit config --global color.branch auto\r\ngit config --global color.interactive auto\r\ngit config --global --unset http.proxy                    # remove  proxy configuration on git\r\ngit clone git+ssh:\/\/git@192.168.53.168\/VT.git             # clone\u8fdc\u7a0b\u4ed3\u5e93\r\ngit status                                                # \u67e5\u770b\u5f53\u524d\u7248\u672c\u72b6\u6001\uff08\u662f\u5426\u4fee\u6539\uff09\r\ngit add xyz                                               # \u6dfb\u52a0xyz\u6587\u4ef6\u81f3index\r\ngit add .                                                 # \u589e\u52a0\u5f53\u524d\u5b50\u76ee\u5f55\u4e0b\u6240\u6709\u66f4\u6539\u8fc7\u7684\u6587\u4ef6\u81f3index\r\ngit commit -m 'xxx'                                       # \u63d0\u4ea4\r\ngit commit --amend -m 'xxx'                               # \u5408\u5e76\u4e0a\u4e00\u6b21\u63d0\u4ea4\uff08\u7528\u4e8e\u53cd\u590d\u4fee\u6539\uff09\r\ngit commit -am 'xxx'                                      # \u5c06add\u548ccommit\u5408\u4e3a\u4e00\u6b65\r\ngit rm xxx                                                # \u5220\u9664index\u4e2d\u7684\u6587\u4ef6\r\ngit rm -r *                                               # \u9012\u5f52\u5220\u9664\r\ngit log                                                   # \u663e\u793a\u63d0\u4ea4\u65e5\u5fd7\r\ngit log -1                                                # \u663e\u793a1\u884c\u65e5\u5fd7 -n\u4e3an\u884c\r\ngit log -5\r\ngit log --stat                                            # \u663e\u793a\u63d0\u4ea4\u65e5\u5fd7\u53ca\u76f8\u5173\u53d8\u52a8\u6587\u4ef6\r\ngit log -p -m\r\ngit show dfb02e6e4f2f7b573337763e5c0013802e392818         # \u663e\u793a\u67d0\u4e2a\u63d0\u4ea4\u7684\u8be6\u7ec6\u5185\u5bb9\r\ngit show dfb02                                            # \u53ef\u53ea\u7528commitid\u7684\u524d\u51e0\u4f4d\r\ngit show HEAD                                             # \u663e\u793aHEAD\u63d0\u4ea4\u65e5\u5fd7\r\ngit show HEAD^                                            # \u663e\u793aHEAD\u7684\u7236\uff08\u4e0a\u4e00\u4e2a\u7248\u672c\uff09\u7684\u63d0\u4ea4\u65e5\u5fd7 ^^\u4e3a\u4e0a\u4e24\u4e2a\u7248\u672c ^5\u4e3a\u4e0a5\u4e2a\u7248\u672c\r\ngit tag                                                   # \u663e\u793a\u5df2\u5b58\u5728\u7684tag\r\ngit tag -a v2.0 -m 'xxx'                                  # \u589e\u52a0v2.0\u7684tag\r\ngit show v2.0                                             # \u663e\u793av2.0\u7684\u65e5\u5fd7\u53ca\u8be6\u7ec6\u5185\u5bb9\r\ngit log v2.0                                              # \u663e\u793av2.0\u7684\u65e5\u5fd7\r\ngit diff                                                  # \u663e\u793a\u6240\u6709\u672a\u6dfb\u52a0\u81f3index\u7684\u53d8\u66f4\r\ngit diff --cached                                         # \u663e\u793a\u6240\u6709\u5df2\u6dfb\u52a0index\u4f46\u8fd8\u672acommit\u7684\u53d8\u66f4\r\ngit diff HEAD^                                            # \u6bd4\u8f83\u4e0e\u4e0a\u4e00\u4e2a\u7248\u672c\u7684\u5dee\u5f02\r\ngit diff HEAD -- .\/lib                                    # \u6bd4\u8f83\u4e0eHEAD\u7248\u672clib\u76ee\u5f55\u7684\u5dee\u5f02\r\ngit diff origin\/master..master                            # \u6bd4\u8f83\u8fdc\u7a0b\u5206\u652fmaster\u4e0a\u6709\u672c\u5730\u5206\u652fmaster\u4e0a\u6ca1\u6709\u7684\r\ngit diff origin\/master..master --stat                     # \u53ea\u663e\u793a\u5dee\u5f02\u7684\u6587\u4ef6\uff0c\u4e0d\u663e\u793a\u5177\u4f53\u5185\u5bb9\r\ngit remote add origin git+ssh:\/\/git@192.168.53.168\/VT.git # \u589e\u52a0\u8fdc\u7a0b\u5b9a\u4e49\uff08\u7528\u4e8epush\/pull\/fetch\uff09\r\ngit branch                                                # \u663e\u793a\u672c\u5730\u5206\u652f\r\ngit branch --contains 50089                               # \u663e\u793a\u5305\u542b\u63d0\u4ea450089\u7684\u5206\u652f\r\ngit branch -a                                             # \u663e\u793a\u6240\u6709\u5206\u652f\r\ngit branch -r                                             # \u663e\u793a\u6240\u6709\u539f\u521b\u5206\u652f\r\ngit branch --merged                                       # \u663e\u793a\u6240\u6709\u5df2\u5408\u5e76\u5230\u5f53\u524d\u5206\u652f\u7684\u5206\u652f\r\ngit branch --no-merged                                    # \u663e\u793a\u6240\u6709\u672a\u5408\u5e76\u5230\u5f53\u524d\u5206\u652f\u7684\u5206\u652f\r\ngit branch -m master master_copy                          # \u672c\u5730\u5206\u652f\u6539\u540d\r\ngit checkout -b master_copy                               # \u4ece\u5f53\u524d\u5206\u652f\u521b\u5efa\u65b0\u5206\u652fmaster_copy\u5e76\u68c0\u51fa\r\ngit checkout -b master master_copy                        # \u4e0a\u9762\u7684\u5b8c\u6574\u7248\r\ngit checkout features\/performance                         # \u68c0\u51fa\u5df2\u5b58\u5728\u7684features\/performance\u5206\u652f\r\ngit checkout --track hotfixes\/BJVEP933                    # \u68c0\u51fa\u8fdc\u7a0b\u5206\u652fhotfixes\/BJVEP933\u5e76\u521b\u5efa\u672c\u5730\u8ddf\u8e2a\u5206\u652f\r\ngit checkout v2.0                                         # \u68c0\u51fa\u7248\u672cv2.0\r\ngit checkout -b devel origin\/develop                      # \u4ece\u8fdc\u7a0b\u5206\u652fdevelop\u521b\u5efa\u65b0\u672c\u5730\u5206\u652fdevel\u5e76\u68c0\u51fa\r\ngit checkout -- README                                    # \u68c0\u51fahead\u7248\u672c\u7684README\u6587\u4ef6\uff08\u53ef\u7528\u4e8e\u4fee\u6539\u9519\u8bef\u56de\u9000\uff09\r\ngit merge origin\/master                                   # \u5408\u5e76\u8fdc\u7a0bmaster\u5206\u652f\u81f3\u5f53\u524d\u5206\u652f\r\ngit cherry-pick ff44785404a8e                             # \u5408\u5e76\u63d0\u4ea4ff44785404a8e\u7684\u4fee\u6539\r\ngit push origin master                                    # \u5c06\u5f53\u524d\u5206\u652fpush\u5230\u8fdc\u7a0bmaster\u5206\u652f\r\ngit push origin :hotfixes\/BJVEP933                        # \u5220\u9664\u8fdc\u7a0b\u4ed3\u5e93\u7684hotfixes\/BJVEP933\u5206\u652f\r\ngit push --tags                                           # \u628a\u6240\u6709tag\u63a8\u9001\u5230\u8fdc\u7a0b\u4ed3\u5e93\r\ngit fetch                                                 # \u83b7\u53d6\u6240\u6709\u8fdc\u7a0b\u5206\u652f\uff08\u4e0d\u66f4\u65b0\u672c\u5730\u5206\u652f\uff0c\u53e6\u9700merge\uff09\r\ngit fetch --prune                                         # \u83b7\u53d6\u6240\u6709\u539f\u521b\u5206\u652f\u5e76\u6e05\u9664\u670d\u52a1\u5668\u4e0a\u5df2\u5220\u6389\u7684\u5206\u652f\r\ngit pull origin master                                    # \u83b7\u53d6\u8fdc\u7a0b\u5206\u652fmaster\u5e76merge\u5230\u5f53\u524d\u5206\u652f\r\ngit mv README README2                                     # \u91cd\u547d\u540d\u6587\u4ef6README\u4e3aREADME2\r\ngit reset --hard HEAD                                     # \u5c06\u5f53\u524d\u7248\u672c\u91cd\u7f6e\u4e3aHEAD\uff08\u901a\u5e38\u7528\u4e8emerge\u5931\u8d25\u56de\u9000\uff09\r\ngit rebase\r\ngit branch -d hotfixes\/BJVEP933                           # \u5220\u9664\u5206\u652fhotfixes\/BJVEP933\uff08\u672c\u5206\u652f\u4fee\u6539\u5df2\u5408\u5e76\u5230\u5176\u4ed6\u5206\u652f\uff09\r\ngit branch -D hotfixes\/BJVEP933                           # \u5f3a\u5236\u5220\u9664\u5206\u652fhotfixes\/BJVEP933\r\ngit ls-files                                              # \u5217\u51fagit index\u5305\u542b\u7684\u6587\u4ef6\r\ngit show-branch                                           # \u56fe\u793a\u5f53\u524d\u5206\u652f\u5386\u53f2\r\ngit show-branch --all                                     # \u56fe\u793a\u6240\u6709\u5206\u652f\u5386\u53f2\r\ngit whatchanged                                           # \u663e\u793a\u63d0\u4ea4\u5386\u53f2\u5bf9\u5e94\u7684\u6587\u4ef6\u4fee\u6539\r\ngit revert dfb02e6e4f2f7b573337763e5c0013802e392818       # \u64a4\u9500\u63d0\u4ea4dfb02e6e4f2f7b573337763e5c0013802e392818\r\ngit ls-tree HEAD                                          # \u5185\u90e8\u547d\u4ee4\uff1a\u663e\u793a\u67d0\u4e2agit\u5bf9\u8c61\r\ngit rev-parse v2.0                                        # \u5185\u90e8\u547d\u4ee4\uff1a\u663e\u793a\u67d0\u4e2aref\u5bf9\u4e8e\u7684SHA1 HASH\r\ngit reflog                                                # \u663e\u793a\u6240\u6709\u63d0\u4ea4\uff0c\u5305\u62ec\u5b64\u7acb\u8282\u70b9\r\ngit show HEAD@{5}\r\ngit show master@{yesterday}                               # \u663e\u793amaster\u5206\u652f\u6628\u5929\u7684\u72b6\u6001\r\ngit log --pretty=format:'%h %s' --graph                   # \u56fe\u793a\u63d0\u4ea4\u65e5\u5fd7\r\ngit show HEAD~3\r\ngit show -s --pretty=raw 2be7fcb476\r\ngit stash                                                 # \u6682\u5b58\u5f53\u524d\u4fee\u6539\uff0c\u5c06\u6240\u6709\u81f3\u4e3aHEAD\u72b6\u6001\r\ngit stash list                                            # \u67e5\u770b\u6240\u6709\u6682\u5b58\r\ngit stash show -p stash@{0}                               # \u53c2\u8003\u7b2c\u4e00\u6b21\u6682\u5b58\r\ngit stash apply stash@{0}                                 # \u5e94\u7528\u7b2c\u4e00\u6b21\u6682\u5b58\r\ngit grep \"delete from\"                                    # \u6587\u4ef6\u4e2d\u641c\u7d22\u6587\u672c\u201cdelete from\u201d\r\ngit grep -e '#define' --and -e SORT_DIRENT\r\ngit gc\r\ngit fsck<\/pre>\n<\/div>\n<p>\u6e90\u5730\u5740\uff1a<a title=\"https:\/\/gist.github.com\/guweigang\/9848271\" href=\"https:\/\/gist.github.com\/guweigang\/9848271\" target=\"_blank\">https:\/\/gist.github.com\/guweigang\/9848271<\/a><\/p>\n<p>\u8f6c\u8f7d\u8bf7\u6ce8\u660e\uff1a<a href=\"https:\/\/www.chenweikang.top\">\u5de6\u624b\u4ee3\u7801\u53f3\u624b\u8bd7<\/a> &raquo; <a href=\"https:\/\/www.chenweikang.top\/?p=341\">GIT\u5e38\u7528\u547d\u4ee4\u5927\u5168<\/a><\/p><div class=\"__youshang\">\r\n            <div id=\"__youshang_popup\" class=\"wechat popup\" style=\"display: none;\">\r\n                <div class=\"head\">~\u8c22\u8c22\u6253\u8d4f~<\/div>\r\n                <div class=\"qrcode\"><div class=\"qrcode-li wechat\" ><img src=\"https:\/\/www.chenweikang.top\/wp-content\/uploads\/2019\/07\/wexin.png\" \/><\/div><div class=\"qrcode-li alipay\" style=\"display:none;\"><img src=\"https:\/\/www.chenweikang.top\/wp-content\/uploads\/2019\/07\/ali-pay.png\" \/><\/div><div class=\"qrcode-li hongbao\" style=\"display:none;\"><img src=\"https:\/\/www.chenweikang.top\/wp-content\/uploads\/2019\/07\/ali-hongbao.png\" \/><\/div><\/div>\r\n                <ul class=\"platform\"><li class=\"icon-wechat active\" data-bg-color=\"#05af4e\" data-thanks=\"~\u8c22\u8c22\u6253\u8d4f~\"><\/li><li class=\"icon-alipay \" data-bg-color=\"#00a2ea\" data-thanks=\"~\u8c22\u8c22\u6253\u8d4f~\"><\/li><li class=\"icon-hongbao \" data-bg-color=\"#dd5746\" data-thanks=\"<p>\u626b\u7801\u9886\u7ea2\u5305<\/p><p style='margin-top: 24px;'>\uff08\u4f59\u989d\u5b9d\u652f\u4ed8\u65f6\u53ef\u62b5\u73b0\uff09<\/p>\"><\/li><\/ul>\r\n            <\/div>\r\n            <a href=\"javascript:void(0);\" id=\"__youshang_btn\">\u8d4f<\/a>\r\n        <\/div>","protected":false},"excerpt":{"rendered":"<p>Git\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u5206\u5e03\u5f0f\u7248\u672c\u63a7\u5236\u7cfb\u7edf\uff0c\u53ef\u4ee5\u6709\u6548\u3001\u9ad8\u901f\u7684\u5904\u7406\u4ece\u5f88\u5c0f\u5230\u975e\u5e38\u5927\u7684\u9879\u76ee\u7248\u672c\u7ba1\u7406\u3002 \u00a0Git \u662f Lin [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":342,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[20],"class_list":["post-341","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-website","tag-java"],"_links":{"self":[{"href":"https:\/\/www.chenweikang.top\/index.php?rest_route=\/wp\/v2\/posts\/341","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.chenweikang.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.chenweikang.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.chenweikang.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.chenweikang.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=341"}],"version-history":[{"count":0,"href":"https:\/\/www.chenweikang.top\/index.php?rest_route=\/wp\/v2\/posts\/341\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.chenweikang.top\/index.php?rest_route=\/wp\/v2\/media\/342"}],"wp:attachment":[{"href":"https:\/\/www.chenweikang.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=341"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.chenweikang.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=341"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.chenweikang.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=341"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}