{"id":210233,"date":"2021-01-28T10:00:20","date_gmt":"2021-01-28T02:00:20","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=210233"},"modified":"2021-01-24T15:03:48","modified_gmt":"2021-01-24T07:03:48","slug":"git-command-record","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/git-command-record.html","title":{"rendered":"Git\u5e38\u7528\u547d\u4ee4\u8bb0\u5f55"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nGit\u662f\u76ee\u524d\u4e16\u754c\u4e0a\u6700\u5148\u8fdb\u7684\u5206\u5e03\u5f0f\u7248\u672c\u63a7\u5236\u7cfb\u7edf\uff0c\u6211\u4eec\u5728\u5f00\u53d1\u7684\u65f6\u5019\u7ecf\u5e38\u7528\u5230\uff0c\u6240\u4ee5\u8fd9\u91cc\u6574\u7406\u4e86\u4e00\u4e9b\u5e38\u7528\u7684git\u547d\u4ee4\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u521b\u5efa\u65b0\u7684git\u4ed3\u5e93<\/strong><\/div>\n
\r\ngit init # \u521d\u59cb\u5316\r\ngit add readme.md # \u6dfb\u52a0\u65b0\u6587\u4ef6\r\ngit commit -am \"some description\" \r\ngit remote add origin  [\u8fdc\u7aef\u5730\u5740]  # \u6dfb\u52a0\u8fdc\u7aef\u4ed3\u5e93\u5730\u5740\r\ngit push -u origin master # \u63d0\u4ea4\u5230\u8fdc\u7aef\r\n<\/pre>\n
\u5728\u65b0\u4ed3\u5e93\u4e2d\u521b\u5efa\u5206\u652f<\/strong><\/div>\n
\r\ngit branch newbranch # \u5728\u672c\u5730\u521b\u5efa\u5206\u652f\r\ngit checkout newbranch # \u5207\u6362\u5230\u65b0\u5206\u652f\r\ngit push origin newbranch # \u5c06\u65b0\u5206\u652f\u63d0\u4ea4\u5230\u8fdc\u7aef\r\ngit branch -d newbranch # \u5220\u9664\u672c\u5730\u5206\u652f\r\ngit psuh origin :newbranch # \u5220\u9664\u8fdc\u7aef\u5206\u652f\uff0c\u5206\u652f\u524d\u7684\u5192\u53f7\u4ee3\u8868\u5220\u9664\r\n<\/pre>\n
\u64cd\u4f5c\u8fdc\u7aef\u5206\u652f<\/strong><\/div>\n
\r\ngit branch -a # \u67e5\u770b\u6709\u54ea\u4e9b\u8fdc\u7aef\u5206\u652f\r\ngit branch -a # \u67e5\u770b\u6709\u54ea\u4e9b\u8fdc\u7aef\u5206\u652f,\u5e76\u663e\u793a\u6700\u540e\u4e00\u4e0bcommit\u4fe1\u606f\r\ngit push origin --delete [\u8fdc\u7aef\u5206\u652f\u540d\u79f0] # \u5220\u9664\u6307\u5b9a\u8fdc\u7aef\u5206\u652f\r\n<\/pre>\n
\u7248\u672c\u56de\u9000<\/strong><\/div>\n
\r\ngit log # \u663e\u793a\u63d0\u4ea4\u65e5\u5fd7\uff0c\u5c55\u793a\u4e0d\u90a3\u4e48\u6f02\u4eae\r\ngit log --pretty=oneline # \u67e5\u770b\u63d0\u4ea4\u65e5\u5fd7\uff0c\u5728\u4e00\u884c\u5c55\u793a\uff0c\u66f4\u6f02\u4eae\r\ngit reset --hard [commit id] # \u901a\u8fc7git log \u67e5\u770b\u63d0\u4ea4\u5386\u53f2\u4ee5\u786e\u5b9a\u8981\u56de\u5230\u7684\u4f4d\u7f6e\uff0c\u5e76\u62ff\u5230\u60f3\u56de\u5230\u7684commit id \u6267\u884c\u4e4b\r\ngit reflog # \u67e5\u770b\u6240\u6709\u6267\u884c\u7684git\u547d\u4ee4 \u53ef\u4ee5\u7528\u6765\u67e5\u627e\u56de\u6eda\u4e4b\u524d\u7684 commit id \u5728\u4f7f\u7528git reset --hard \u56de\u6eda\u8fc7\u53bb\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

git init # \u521d\u59cb\u5316 git add readme.md # \u6dfb\u52a0\u65b0\u6587\u4ef6 git commit -am […]<\/p>\n","protected":false},"author":1903,"featured_media":95067,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-210233","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/210233","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1903"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=210233"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/210233\/revisions"}],"predecessor-version":[{"id":210239,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/210233\/revisions\/210239"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/95067"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=210233"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=210233"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=210233"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}