{"id":1062,"date":"2019-10-24T10:00:48","date_gmt":"2019-10-24T02:00:48","guid":{"rendered":"http:\/\/iqotom.com\/?p=1062"},"modified":"2019-10-24T10:44:55","modified_gmt":"2019-10-24T02:44:55","slug":"git%e5%91%bd%e4%bb%a4%e7%9a%84%e4%b8%80%e4%ba%9b%e6%80%bb%e7%bb%931","status":"publish","type":"post","link":"http:\/\/iqotom.com\/?p=1062","title":{"rendered":"Git\u547d\u4ee4\u7684\u4e00\u4e9b\u603b\u7ed31"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">\u524d\u8a00<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">\u8bb0\u5f55\u4e00\u4e9b\u5de5\u4f5c\u4e2d\u5e38\u7528\u7684git\u547d\u4ee4\uff0c\u4ee5\u4fbf\u7ecf\u540e\u67e5\u9605<\/h3>\n\n\n\n<p> \u300a<a href=\"http:\/\/iqotom.com\/?p=1062\">Git\u547d\u4ee4\u7684\u4e00\u4e9b\u603b\u7ed31<\/a>\u300b<br> \u300a<a href=\"http:\/\/iqotom.com\/?p=1069\">Git\u547d\u4ee4\u7684\u4e00\u4e9b\u603b\u7ed32<\/a>\u300b <\/p>\n\n\n\n<p> \u514b\u9686\u9879\u76ee : git clone git:\/\/github.com\/***\/***.git <\/p>\n\n\n\n<p> \u67e5\u770b\u8fdc\u7a0b\u4ed3\u5e93\uff1agit remote -v <\/p>\n\n\n\n<p> \u6dfb\u52a0\u8fdc\u7a0b\u4ed3\u5e93\uff1agit remote add [name] [url] <\/p>\n\n\n\n<p> \u62c9\u53d6\u8fdc\u7a0b\u4ed3\u5e93\uff1agit pull [remoteName] [localBranchName] <br> git pull origin master&nbsp;\/\/\u5c06\u8fdc\u7a0borigin\u4ed3\u5e93\u4ee3\u7801\u66f4\u65b0\u5230\u672c\u5730\u7684master\u5206\u652f <\/p>\n\n\n\n<p> \u63a8\u9001\u8fdc\u7a0b\u4ed3\u5e93\uff1agit push [remoteName] [localBranchName] <br> git push origin test:master&nbsp;&nbsp; \/\/ \u63d0\u4ea4\u672c\u5730test\u5206\u652f\u4f5c\u4e3a\u8fdc\u7a0bmaster\u5206\u652f <\/p>\n\n\n\n<p> \u67e5\u770b\u672c\u5730\u5206\u652f\uff1agit branch <\/p>\n\n\n\n<p> \u67e5\u770b\u8fdc\u7a0b\u5206\u652f\uff1agit branch -r&nbsp; \/\/\u7ea2\u8272\u7684\u4ee3\u8868\u8fdc\u7a0b\u5206\u652f <\/p>\n\n\n\n<p> \u67e5\u770b\u6240\u6709\u5206\u652f\uff1agit branch -a <\/p>\n\n\n\n<p> \u521b\u5efa\u672c\u5730\u5206\u652f\uff1agit branch [name] <\/p>\n\n\n\n<p> \u5207\u6362\u5206\u652f\uff1agit checkout [name] <\/p>\n\n\n\n<p> \u64a4\u9500\u5c1a\u672a\u63d0\u4ea4\u7684\u6240\u6709\u4fee\u6539 \uff1a git checkout head . <\/p>\n\n\n\n<p> \u5408\u5e76\u5206\u652f\uff1agit merge [name]&nbsp;&nbsp;&nbsp; \/\/\u5c06name\u5206\u652f\u4e0e\u5f53\u524d\u5206\u652f\u5408\u5e76 <\/p>\n\n\n\n<p> \u67e5\u770b\u7248\u672c\uff1agit tag <\/p>\n\n\n\n<p> \u67e5\u770b\u8fdc\u7a0b\u7248\u672c\uff1agit tag -r <\/p>\n\n\n\n<p><strong> \u67e5\u770b\u5386\u53f2\u65e5\u5fd7 \uff1a<\/strong><\/p>\n\n\n\n<ol><li> git log <\/li><li> git log -p filename&nbsp;&nbsp; \/\/\u67e5\u770bfilename\u7684log\u65e5\u5fd7\uff0c-p\u7684\u610f\u601d\u662f\u5c55\u5f00\u6bcf\u6b21\u7684\u63d0\u4ea4\u5dee\u5f02 <\/li><li> git log -p -2&nbsp; \/\/ \u53ea\u663e\u793a\u6700\u8fd1\u7684\u4e24\u6b21log <\/li><li> git log &#8211;stat&nbsp;&nbsp; \/\/\u7b80\u5355\u7684log\u7edf\u8ba1 <\/li><li> git log &#8211;author=username<\/li><\/ol>\n\n\n\n<p> \u4ece\u8fdc\u7aef\u4ed3\u5e93\u83b7\u53d6\u4ee3\u7801\u5230\u672c\u5730\uff0c\u4e0d\u4f1a\u81ea\u52a8merge <br> git fetch <br> git fetch origin <\/p>\n\n\n\n<p> \u67e5\u770b\u672c\u5730\u4ed3\u5e93\u7684\u72b6\u6001 \uff1a git status <\/p>\n\n\n\n<p> <strong>\u7b2c\u4e00\u6b21\u5728\u7528\u6237Home\u76ee\u5f55\u4f7f\u7528git\uff1a <\/strong><\/p>\n\n\n\n<ol><li> git config &#8211;global user.name &#8220;username&#8221; <\/li><li> git config &#8211;global user.email &#8220;<a href=\"mailto:huchanghui1@huawei.com\">email@gmail.com<\/a>&#8221; <\/li><li> rm -rf ~\/.repoconfig <\/li><li> repo init -u&nbsp;<a href=\"mailto:git@10.85.168.56:manifest\">git@ip:manifest<\/a> \/\/\u83b7\u53d6\u4ed3\u5e93\u5217\u8868<\/li><li> repo sync \/\/\u66f4\u65b0\u6574\u4e2a\u9879\u76ee<\/li><\/ol>\n\n\n\n<p> <strong>\u4f8b\u5b50\uff1a\u4ece\u8fdc\u7a0b\u4ed3\u5e93\u83b7\u53d6\u6700\u65b0\u7248\u672c\u5230\u672c\u5730 <\/strong><\/p>\n\n\n\n<ol><li> git remote -v&nbsp;&nbsp; \/\/\u67e5\u770b\u8fdc\u7a0b\u4ed3\u5e93 <\/li><li> git fetch origin master:temp&nbsp;&nbsp;&nbsp; \/\/\u4ece\u8fdc\u7a0borigin\u4ed3\u5e93\u7684master\u5206\u652f\u4e0b\u8f7d\u4ee3\u7801\u5230\u672c\u5730\u5e76\u65b0\u5efa\u4e00\u4e2a\u5206\u652ftemp <\/li><li> git diff temp&nbsp;&nbsp; \/\/\u6bd4\u8f83\u672c\u5730master\u5206\u652f\u4e0etemp\u5206\u652f\u7684\u4e0d\u540c <\/li><li> git merge temp&nbsp;&nbsp;&nbsp; \/\/\u5408\u5e76temp\u5206\u652f\u5230master\u5206\u652f <\/li><li> git branch -d temp \u6216\u8005 git branch -D temp&nbsp;&nbsp; \/\/\u5220\u9664temp\u5206\u652f <\/li><\/ol>\n\n\n\n<p><strong> \u4f8b\u5b50\uff1arepo sync \u51fa\u73b0\u9519\u8bef\u89e3\u51b3\u65b9\u6cd5\uff1aerror: xxx\/: xxx checkout &#8230;&#8230; <\/strong><\/p>\n\n\n\n<ol><li>cd xxx<\/li><li> git log&nbsp;&nbsp; \/\/\u627e\u5230\u6700\u4e0a\u9762\u4e00\u4e2acommitid <\/li><li> git reset &#8211;hard \u4e0a\u9762\u7684commitid <\/li><li> git checkout <\/li><li> git fetch &#8211;all <\/li><li> git reset &#8211;hard origin\/master <\/li><li> git branch <\/li><li> repo sync <\/li><\/ol>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00 \u8bb0\u5f55\u4e00\u4e9b\u5de5\u4f5c\u4e2d\u5e38\u7528\u7684git\u547d\u4ee4\uff0c\u4ee5\u4fbf\u7ecf\u540e\u67e5\u9605 \u300aGit\u547d\u4ee4\u7684\u4e00\u4e9b\u603b\u7ed31\u300b \u300aGit\u547d\u4ee4\u7684\u4e00\u4e9b\u603b\u7ed32\u300b \u514b\u2026 <span class=\"read-more\"><a href=\"http:\/\/iqotom.com\/?p=1062\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":1063,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[81],"tags":[89],"_links":{"self":[{"href":"http:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/posts\/1062"}],"collection":[{"href":"http:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/iqotom.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1062"}],"version-history":[{"count":6,"href":"http:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/posts\/1062\/revisions"}],"predecessor-version":[{"id":1073,"href":"http:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/posts\/1062\/revisions\/1073"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/media\/1063"}],"wp:attachment":[{"href":"http:\/\/iqotom.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1062"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/iqotom.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1062"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/iqotom.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1062"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}