{"id":149,"date":"2018-12-26T22:25:38","date_gmt":"2018-12-26T14:25:38","guid":{"rendered":"https:\/\/www.ientertech.com\/blog\/?p=149"},"modified":"2018-12-26T22:25:38","modified_gmt":"2018-12-26T14:25:38","slug":"git-%e4%bd%bf%e7%94%a8%e6%80%bb%e7%bb%93","status":"publish","type":"post","link":"https:\/\/www.ienter.com.cn\/blog\/2018\/12\/git-%e4%bd%bf%e7%94%a8%e6%80%bb%e7%bb%93.html","title":{"rendered":"Git \u4f7f\u7528\u603b\u7ed3"},"content":{"rendered":"<p>\u4e0b\u8f7d\u5730\u5740\uff1ahttps:\/\/git-scm.com\/\u3010git\u6e90\u7801\uff1ahttps:\/\/github.com\/git\/git\u3011<\/p>\n<p>####\u9644\u5927\u795e\u6559\u7a0b\uff1ahttps:\/\/www.liaoxuefeng.com\/####<\/p>\n<p>\u4e0b\u8f7d\u5bf9\u5e94\u7cfb\u7edf\u7684\u7248\u672c\uff0c\u5b89\u88c5\u7701\u7565\uff0c\u4e0b\u9762\u603b\u7ed3\u662f\u7531\u300aGitHub\u5165\u95e8\u4e0e\u5b9e\u8df5\u300b\u4e00\u672c\u5b66\u4e60\u603b\u7ed3\u800c\u6210\u3002<\/p>\n<p><font size=\"6\">\u7b2c\u4e00\u90e8\u5206\u2014\u2014\u57fa\u672c\u64cd\u4f5c<\/font><\/p>\n<p>\u4e00\u3001Git Bash\u91cc\u8bbe\u7f6e\u7528\u6237\u540d\u4e0e\u90ae\u7bb1<\/p>\n<p>#git config --global user.name \"name\"<\/p>\n<p>#git config --global user.email \"email\"<\/p>\n<p>\u4fe1\u606f\u4fdd\u5b58\u5728\u201c.gitconfig\u201d\u6587\u4ef6\u4e2d\uff0c\u5c5e\u6027\u4e3a\u9690\u85cf\uff0cwindows\u5728\u201cC:\\Users\\\u7528\u6237\u540d\u201d\u4e0b\uff0cLinux\u5728\u201c\/home\/\u7528\u6237\u540d\/\u201d\u4e0b<\/p>\n<p>\u4e8c\u3001\u7740\u8272\u914d\u7f6e<\/p>\n<p>#git config --global coulor.ui auto&nbsp; \/\/\u989c\u8272\u81ea\u52a8<\/p>\n<p>\u4e09\u3001\u751f\u6210\u7528\u4e8eSSH\u8fde\u63a5\u7684SSH key<\/p>\n<p>#ssh-key -t rsa -C \"e_mail\"<\/p>\n<p>\u516c\u94a5\uff1awindows\u9ed8\u8ba4\u4fdd\u5b58\u201cC:\\Users\\\u7528\u6237\u540d\\.ssh\\id_rsa.pub\u201d\uff0cUbuntu\u9ed8\u8ba4\u4fdd\u5b58\u201c\/root\/.ssh\/id_rsa.pub\u201d\u3002<\/p>\n<p>\u79c1\u94a5\uff1awindows\u9ed8\u8ba4\u4fdd\u5b58\u201cC:\\Users\\\u7528\u6237\u540d\\.ssh\\id_rsa\u201d\uff0cUbuntu\u9ed8\u8ba4\u4fdd\u5b58\u201c\/root\/.ssh\/id_rsa\u201d\u3002<\/p>\n<p>\u4fdd\u5b58\u4f4d\u7f6e\u7684known_hosts\u662f\u7528\u4e8e\u4fdd\u5b58ssh\u767b\u5f55\u8fdc\u7a0b\u7cfb\u7edf\u7684\u516c\u94a5<\/p>\n<p>\u4f7f\u7528GitHub\u7684\u65f6\u5019\uff0c\u516c\u94a5\u653e\u5728\u8bbe\u7f6e\u4e2d\u7684ssh\u9009\u9879\u4e2d\uff0c\u53ef\u4ee5\u653e\u7f6e\u591a\u4e2assh\uff0c\u7528\u4e8e\u4e0d\u540c\u7684\u7535\u8111\u53bb\u540c\u6b65\u540c\u4e00\u4e2a\u9879\u76ee<\/p>\n<p>\u56db\u3001\u521d\u59cb\u5316\u4ed3\u5e93<\/p>\n<p>#git init<\/p>\n<p>\u7528\u4e8e\u521d\u59cb\u5316\u4ed3\u5e93\uff0c\u672c\u5730\u65b0\u5efa\u4e00\u4e2a\u4ed3\u5e93\u7684\u65f6\u5019\u4f7f\u7528\uff0c\u5982\u679cGitHub\u4e0a\u76f4\u63a5\u65b0\u5efa\uff0c\u672c\u5730\u4e0d\u9700\u8981\u505a\u8fd9\u4e00\u6b65\uff0c\u76f4\u63a5clone\u8fdc\u7a0b\u5230\u672c\u5730\u5c31\u53ef\u4ee5\u3002<\/p>\n<p>\u4e94\u3001\u67e5\u770b\u4ed3\u5e93\u72b6\u6001<\/p>\n<p>#git status<\/p>\n<p>\u67e5\u770b\u5206\u652f\u7b49\u7ea7\uff08master\u7b49\uff09\uff0c\u6587\u4ef6\u4fee\u6539\u72b6\u6001\uff0c\u65b0\u5efa\u4f46\u672a\u6dfb\u52a0\u7684\u6587\u4ef6\uff0c\u4fee\u6539\u8bb0\u5f55\uff0ccommit\u65b0\u7684\u8bb0\u5f55\u7b49\u7b49<\/p>\n<p>\u516d\u3001\u6dfb\u52a0\u6587\u4ef6<\/p>\n<p>#git add file_name<\/p>\n<p>\u5411git \u6682\u5b58\u533a\u6dfb\u52a0\u6587\u4ef6\uff0c\u6dfb\u52a0\u540e\u624d\u53ef\u80fd\u8fdb\u884c\u6b63\u5e38\u7684\u7248\u672c\u7ba1\u7406\u3002<\/p>\n<p>#git add filename1 filename2 filename3<\/p>\n<p>\u53ef\u4ee5\u591a\u4e2a\u6587\u4ef6\u4e00\u8d77\u6dfb\u52a0<\/p>\n<p>\u4e03\u3001\u63d0\u4ea4\uff0c\u4fdd\u5b58\u4ed3\u5e93\u5386\u53f2\u8bb0\u5f55<\/p>\n<p>#git commit<\/p>\n<p>\u5c06\u5f53\u524d\u6682\u5b58\u533a\u7684\u6587\u4ef6\u5b9e\u9645\u4fdd\u5b58\u5230\u4ed3\u5e93\u7684\u5386\u53f2\u8bb0\u5f55\u4e2d\uff0c\u901a\u8fc7\u8fd9\u4e9b\u8bb0\u5f55\uff0c\u53ef\u4ee5\u5728\u5de5\u4f5c\u6811\u4e2d\u590d\u539f\u6587\u4ef6\u3002<\/p>\n<p>\u52a0\u300a-m \u201c\u5b57\u7b26\u4e32\u201d\u300b\u540e\u7f00\uff0c\u7528\u4f5c\u63d0\u4ea4\u8bb0\u5f55\u65f6\u7684\u6587\u5b57\u63cf\u8ff0<\/p>\n<p>#git commit -m \u201cadd a file\u201d<\/p>\n<p>\u5982\u679c\u6ca1\u6709-m\u53c2\u6570\uff0c\u5219\u4f1a\u3010<strong><font color=\"#ff0000\">\u540e\u9762\u6dfb\u52a0<\/font><\/strong>\u3011<\/p>\n<p>\u5982\u679c\u62a5\u201cChange not staged for commit:\u201d\uff0c\u4f1a\u63d0\u793a\u51e0\u4e2a\u4fee\u6539\u8fc7\u7684\u6587\u4ef6\uff0c\u8fd9\u4e9b\u6587\u4ef6\u5728git commit\u8fd9\u524d\u8981add\u4e00\u4e0b\uff0c\u4e5f\u53ef\u4ee5\u6267\u884c\u201c#git add .\u201d\u4e00\u6b21\u5168\u90e8\u6dfb\u52a0\u3002<\/p>\n<p>\u65e0\u66f4\u6539\u7684\u60c5\u51b5\u4e0b\uff0c\u4f1a\u63d0\u793a\uff1anothing to commit, working tree clean<\/p>\n<p>#git commit -am \"message\"<\/p>\n<p>\u8fd9\u662fgit add \u4e0e git commit\u7684\u5408\u4f53\u7528\u6cd5\uff0cmessage\u4e3a\u4fe1\u606f\u63cf\u8ff0\u3002<\/p>\n<p>\u516b\u3001\u67e5\u770b\u63d0\u4ea4\u65e5\u5fd7<\/p>\n<p>#git log<\/p>\n<p>\u67e5\u770b\u4ed3\u5e93\u4e2d\u7684\u63d0\u4ea4\u65e5\u5fd7\u3002\u5305\u62ec\u63d0\u4ea4\u7528\u6237\u7684\u7528\u6237\u540d\u548cemail\uff08\u5728\u201c\u4e00\u3001\u201d\u4e2d\u8bbe\u7f6e\u7684\u7528\u6237\u540d\u548c\u90ae\u7bb1\uff09\uff0c\u63d0\u4ea4\u7684\u65e5\u671f\uff0c\u63d0\u4ea4\u65f6\u7684\u63cf\u8ff0\uff08-m\u53c2\u6570\u5b57\u7b26\u4e32\uff09\uff0c\u6700\u91cd\u8981\u7684\u662f\u63d0\u4ea4\u7684\u54c8\u5e0c\u503c\uff0c<\/p>\n<p>\u52a0\u201c--pretty=short\u201d\uff0c\u663e\u793a\u54c8\u5e0c\u503c\u3001\u63d0\u4ea4\u4eba\u4fe1\u606f\u548c\u63cf\u8ff0\uff0c\u6ca1\u6709\u65e5\u671f\uff0c\u76f8\u5bf9\u6d01\u4e00\u4e9b<\/p>\n<p>\u52a0\u201cdirectory\/filename\u201d\uff0c\u53ef\u4ee5\u9488\u5bf9\u4e00\u4e2a\u6587\u4ef6\u663e\u793a\u65e5\u5fd7\uff0c\u65e5\u5fd7\u683c\u5f0f\u540cgit log<\/p>\n<p>\u52a0\u201c-p\u201d\u53c2\u6570\uff0c\u53ef\u4ee5\u663e\u793a\u63d0\u4ea4\u4fe1\u606f\u524d\u540e\u7684\u6587\u4ef6\u6539\u52a8\u524d\u540e\u5dee\u522b\uff08\u6240\u6709commit\u90fd\u663e\u793a\uff09<\/p>\n<p>\u52a0\u201c-p directory\/filename\u201d\uff0c\u8fd9\u4e24\u7ec4\u53c2\u6570\u7ec4\u5408\u4f7f\u7528\uff0c\u53ef\u4ee5\u9488\u5bf9\u4e00\u4e2a\u6587\u4ef6\u663e\u793a\u524d\u540e\u6539\u52a8\u7684\u5dee\u522b\uff08\u6240\u6709commit\u90fd\u663e\u793a\uff09<\/p>\n<p>\u5f53\u663e\u793a\u7684\u5185\u5bb9\u8d85\u8fc7\u4e00\u5c4f\u65f6\uff0c\u4f1a\u4e00\u5c4f\u4e00\u5c4f\u663e\u793a\uff0c\u6309\u7a7a\u683c\u6362\u5c4f\uff0c\u70b9\u51fb\u201cq\u201d\u952e\u9000\u51fa\u3002<\/p>\n<p>\u52a0\u201c--graph\u201d\u53c2\u6570\uff0c\u53ef\u4ee5\u4ee5\u56fe\u8868\u7684\u5f62\u5f0f\u67e5\u770b\u5206\u652f\uff0c\u5f62\u8c61\uff0c\u975e\u5e38\u76f4\u89c2\u3002<\/p>\n<p>\u4e5d\u3001\u67e5\u770b\u66f4\u65b0\u524d\u540e\u7684\u5dee\u522b<\/p>\n<p>#git diff<\/p>\n<p>\u67e5\u770b\u5f53\u524d\u5de5\u4f5c\u6811\u4e0e\u6682\u5b58\u533a\u6240\u6709\u88ab\u53d8\u66f4\u6587\u4ef6\u7684\u524d\u540e\u5dee\u522b\uff0c\u5bf9\u6682\u5b58\u533a\u64cd\u4f5c\u540e\uff0c\u4e0d\u4f1a\u518d\u663e\u793a\uff0c\u5982git add\u7b49\u64cd\u4f5c\u540e\uff0c\u4e0d\u4f1a\u518d\u663e\u793a\u5dee\u522b<\/p>\n<p>\u53c2\u6570\u201cHEAD\u201d\uff0c\u589e\u52a0\u8fd9\u4e2a\u53c2\u6570\uff0c\u662f\u663e\u793a\u5de5\u4f5c\u6811\u4e0e\u6700\u540e\u4e00\u6b21\u63d0\u4ea4\u7684\u5dee\u522b\uff0c\u6267\u884cgit add\u540e\u4e5f\u4f1a\u663e\u793a\u533a\u522b\uff0c\u5728\u6267\u884cgit commit\u540e\u624d\u4e0d\u4f1a\u663e\u793a\u3002<\/p>\n<p>\u597d\u7684\u4e60\u60ef\uff0c\u5728\u6267\u884cgit commit\u524d\u6267\u884cgit diff HEAD\uff0c\u7136\u540e\u67e5\u770b\u533a\u522b\uff0c\u786e\u8ba4\u65e0\u8bef\u540e\u518d\u8fdb\u884c\u63d0\u4ea4\u3002<\/p>\n<p>\u5341\u3001\u67e5\u770b\u5f53\u524d\u4ed3\u5e93\u64cd\u4f5c\u65e5\u5fd7<\/p>\n<p>#git reflog<\/p>\n<p>\u67e5\u770b\u5f53\u524d\u4ed3\u5e93\u7684\u6240\u6709\u64cd\u4f5c\u65e5\u5fd7\uff08\u53ea\u8981\u4e0d\u8fdb\u884cGit\u7684GC\u64cd\u4f5c\u5c31\u6210\uff09\uff0c\u6bcf\u4e00\u6b65\u90fd\u5bf9\u5e94\u4e00\u4e2a\u54c8\u5e0c\u503c\uff08\u53ea\u663e\u793a7\u4f4d\u2014\u2014\u59347\u4f4d\uff09\u3002<\/p>\n<p>\u5341\u4e00\u3001\u56de\u6eaf\u5386\u53f2\u7248\u672c<\/p>\n<p>#git reset --hard \u54c8\u5e0c\u503c<\/p>\n<p>\u54c8\u5e0c\u503c\u53ef\u4ee5\u4e0d\u7528\u5168\u503c\uff0c\u7528\u524d6\u4f4d\u5c31\u53ef\u4ee5\uff08\u8bf4\u662f4\u4f4d\u4ee5\u4e0a\u5c31ok\uff0c\u4e0d\u77e5\u9053\u5305\u4e0d\u5305\u62ec4\u4f4d\uff09\u3002\u4e4b\u524d\u7684\u8bb0\u5f55\u53ef\u4ee5\u7528git log\u6765\u67e5\u627e\uff0c\u5982\u679c\u4e4b\u524d\u505a\u8fc7\u56de\u6eaf\uff0c\u53ef\u4ee5\u7528git reflog\u6765\u6839\u636e\u64cd\u4f5c\u65e5\u5fd7\u6765\u627e\u3002<\/p>\n<p>\u64cd\u4f5c\u7684\u65f6\u5019\u6ce8\u610f\u5f53\u524d\u64cd\u4f5c\u7684\u5206\u652f\u3010\u4e0d\u786e\u5b9a\u9700\u8981\u4e0d\u9700\u8981\u6ce8\u610f\u3011<\/p>\n<p>\u5341\u4e8c\u3001\u4fee\u6539\u63d0\u4ea4\u4fe1\u606f<\/p>\n<p>#git commit --amend<\/p>\n<p>\u64cd\u4f5c\u540e\u4f1a\u8df3\u51fa\u7f16\u8f91\u5668\uff0c\u7f16\u8f91\u5668\u4e2d\u53ef\u4ee5\u4fee\u6539\u63cf\u8ff0\u4fe1\u606f\uff0c\u4fee\u6539\u5b8c\u6210\u540e\uff0c\u4fdd\u5b58\u9000\u51fa\uff0c\u5c31\u53ef\u4ee5\u5b9e\u73b0\u4fee\u6539\u4e0a\u4e00\u6761\u63d0\u4ea4\u7684\u63cf\u8ff0\u4fe1\u606f\u529f\u80fd\u3002<\/p>\n<p>\u5341\u4e09\u3001\u538b\u7f29\u5386\u53f2<\/p>\n<p>#git rebase -i HEAD~2<\/p>\n<p>\u64cd\u4f5c\u540e\u4f1a\u538b\u7f29\u524d2\u4e2acommit\u8bb0\u5f55\uff0cpickup\u7684\u4f1a\u7559\u4e0b\uff08\u53ef\u4ee5\u6539\u4e00\u4e0b\uff09\uff0cpickup\u6539\u6210fixup\uff0c\u540e\u9762\u7684\u5c31\u5220\u9664\u6389\u4e86\uff0c\u8bb0\u5f55\u5c31\u538b\u7f29\u4e3a\u4e00\u6761\u3002<\/p>\n<p>HEAD\u4e3a\u5934\uff0c2\u4e3a\u4e24\u4e2a\uff0c\u4ece\u5934\u5411\u540e\u6570\uff0c\u538b\u7f292\u4e2a\uff0c\u51993\u5c31\u662f3\u4e2a\uff0c\u5982\u679c\u91cc\u9762\u7684pickup\u4e0d\u6539fixup\uff0c\u90a3\u538b\u7f29\u540e\u7ed3\u679c\u4e0d\u53d8\u3002<\/p>\n<p>\u5341\u56db\u3001\u6dfb\u52a0\u8fdc\u7a0b\u4ed3\u5e93\u3010\u5411\u8fdc\u7a0b\u63a8\u9001\u4e4b\u524d\u5e94\u8be5\u5148\u6dfb\u52a0\u8fdc\u7a0b\u3011<\/p>\n<p>#git remote add origin git@github.com:ientertech\/CentHello.git<\/p>\n<p><font color=\"#000000\">origin\uff0c\u8fd9\u662f\u6807\u8bc6\u7b26\uff0c\u5177\u4f53\u4f5c\u7528\u4e0d\u6e05\u695a\uff0c\u540d\u5b57\u4e5f\u53ef\u4ee5\u6539\uff0c\u4f5c\u7528\u4e0d\u4e0d\u592a\u6e05\u695a\uff0c<\/font><a><a><font color=\"#000000\">\u540d\u5b57\u5728\u4ed3\u5e93\u5f53\u524d\u6587\u4ef6\u5939\u4e0b\u9762\u201c.git\u201d\u6587\u4ef6\u5939\u4e0b\u9762\u7684config\u914d\u7f6e\u6587\u4ef6\u4e2d\u53ef\u4ee5\u67e5\u770b\u5230\u3002<\/font><\/a><font color=\"#000000\">git@github.com:ientertech\/CentHello.git\u4e3a\u8fdc\u7a0b\u4ed3\u5e93\u5730\u5740\uff0c\u672c\u5730\u63a8\u9001\u8fdc\u7a0b\uff0c\u6240\u4ee5\u8fdc\u7a0b\u4ed3\u5e93\u5728\u5efa\u7acb\u7684\u65f6\u5019\u4e0d\u5e94\u8be5\u6dfb\u52a0\u4efb\u52a1\u6587\u4ef6\uff0c\u5305\u62ec\u201c.git\u914d\u7f6e\u6587\u4ef6\u201d\u3002\u5e94\u8be5\u662f\u7a7a\u7a7a\u7684\u4ed3\u5e93\u3002<\/font><\/p>\n<p>origin\u540d\u5b57\u662fgithub\u9ed8\u8ba4\u7684\uff0c\u5c31\u7b97\u4f7f\u7528\u522b\u7684\u540d\u5b57\u4e0a\u4f20\uff0c\u4e5f\u53ea\u662f\u5f53\u524d\u4ed3\u5e93\u4f7f\u7528\uff0c\u5176\u5b83\u7ec8\u7aefgit clone\u81f3\u672c\u5730\u540e\uff0c\u9ed8\u8ba4\u8fd8\u662forigin\u3002<\/p>\n<p>\u5341\u4e94\u3001\u63a8\u9001\u81f3\u8fdc\u7a0b<\/p>\n<p>#git push<\/p>\n<p>\u76f4\u63a5\u63a8\u9001\u8fdc\u7a0b\uff0c\u63a8\u9001\u7684\u4f20\u52a8\u60c5\u51b5\u770b\u5f53\u524d\u5728\u54ea\u4e2a\u5206\u652f\u4e0b\uff0c\u53ef\u4ee5git branch\u770b\u5728\u54ea\u4e2a\u652f\u6301\uff0c\u63a8\u9001\u7684\u65f6\u5019\u5c31\u4f1a\u63a8\u9001\u81f3\u54ea\u4e2a\u5206\u652f\u4e0b\u3002<\/p>\n<p>#git push -u origin master<\/p>\n<p>\u6267\u884c#git push\uff0c\u5f53\u524d\u5206\u652f\u7684\u5185\u5bb9\u5c31\u4f1a\u88ab\u63a8\u9001\u7ed9\u8fdc\u7a0b\u4ed3\u5e93origin\u7684master\u5206\u652f\u3002-u\u53c2\u6570\uff0c\u662f\u5728\u63a8\u9001\u7684\u540c\u65f6\uff0c\u5c06origin\u4ed3\u5e93\u7684master\u5206\u652f\u8bbe\u7f6e\u4e3a\u672c\u5730\u4ed3\u5e93\u5f53\u524d\u5206\u652f\u7684upstream\uff08\u4e0a\u6e38\uff09\u3002\u6dfb\u52a0\u8fd9\u4e2a\u53c2\u6570\u540e\uff0c\u5c06\u6765\u8fd0\u884cgit pull\u547d\u4ee4\u4ece\u8fdc\u7a0b\u4ed3\u5e93\u83b7\u53d6\u5185\u5bb9\u65f6\uff0c\u672c\u5730\u4ed3\u5e93\u7684\u8fd9\u4e2a\u5206\u652f\u5c31\u53ef\u4ee5\u76f4\u63a5\u4eceorigin\u7684master\u5206\u652f\u83b7\u53d6\u5185\u5bb9\uff0c\u6d3b\u52a8\u53e6\u5916\u6dfb\u52a0\u53c2\u6570\u7684\u9ebb\u70e6\u3002<\/p>\n<p>#git checkout -b feature<\/p>\n<p>#git push -u origin feature<\/p>\n<p>\u672c\u5730\u5efa\u8baefeature\u5206\u652f\uff0c\u7136\u540epush\u5206\u652f\u5230\u8fdc\u7a0b\u4ed3\u5e93\uff0c\u8fdc\u7a0b\u4e5f\u540c\u6837\u6709feature\u5206\u652f\u4e86\u3002<\/p>\n<p>\u5341\u516d\u3001\u4ece\u8fdc\u7a0b\u4ed3\u5e93\u83b7\u53d6<\/p>\n<p>#git clone git@github.com:ientertech\/CentHello.git<\/p>\n<p>git clone\u547d\u4ee4\u4f1a\u9ed8\u8ba4\u5904\u4e8emaster\u5206\u652f\u4e0b\uff0c\u540c\u65f6\u7cfb\u7edf\u4f1a\u81ea\u52a8\u5c06origin\u5206\u652f\u4e0eGitHub\u8fdc\u7a0b\u4ed3\u5e93\uff08origin\uff09\u7684master\u5206\u652f\u5728\u5185\u5bb9\u662f\u5b8c\u5168\u76f8\u540c<\/p>\n<p>git clone \u6267\u884c\u7684\u65f6\u5019\u4f1a\u4e0b\u8f7d\u8fdc\u7a0b\u7684\u4ed3\u5e93\uff0c\u5230\u672c\u5730\u540e\u662f\u4e00\u4e2a\u6587\u4ef6\u5939\uff0c\u6240\u4ee5\u5728\u6267\u884c\u7684\u65f6\u5019\u4e0d\u9700\u8981\u65b0\u5efa\u4e00\u4e2a\u6587\u4ef6\u5939\uff0c\u76f4\u63a5\u6267\u884c\u540e\uff0c\u4ed3\u5e93\u81ea\u5e26\u4e00\u4e2a\u6587\u4ef6\u5939\u3002<\/p>\n<p>#git checkout -b feature origin\/feature<\/p>\n<p>\u8fd9\u662f\u4e3a\u4e86\u628a\u8fdc\u7a0b\u4ed3\u5e93\u7684\u5206\u652fclone\u81f3\u672c\u5730\uff0cfeature\u4e3a\u672c\u5730\u547d\u540d\uff0c\u5e94\u8be5\u548c\u8fdc\u7a0b\u4e00\u6837\uff0corigin\/feature\u4e3a\u8fdc\u7a0b\u5206\u652f\uff0c\u53ef\u4ee5\u7528#git branch -a\u6765\u67e5\u770b\u8fdc\u7a0b\u5206\u652f\u4fe1\u606f\u3002<\/p>\n<p><\/p>\n<p><\/p>\n<p><font size=\"6\">\u7b2c\u4e8c\u90e8\u5206\u2014\u2014\u5206\u652f\u64cd\u4f5c<\/font><\/p>\n<p>\u57fa\u4e8e\u7279\u5b9a\u4e3b\u9898\u7684\u4f5c\u4e1a\u5728\u7279\u6027\u5206\u652f\u4e2d\u8fdb\u884c\uff0c\u5b8c\u6210\u540e\u518d\u4e0emastar\u5206\u652f\u5408\u5e76\u3002<\/p>\n<p>\u4e00\u3001\u663e\u793a\u5206\u652f\u4e00\u89c8\u8868<\/p>\n<p>#git branch<\/p>\n<p>\u5c06\u5206\u652f\u8fdb\u884c\u5217\u8868\u663e\u793a\uff0c\u5206\u652f\u540d\u524d\u5e26\u201c*\u201d\u7684\u4e3a\u5f53\u7136\u6240\u5728\u5206\u652f\uff0c\u4e3b\u5206\u652f\u4e3amaster\u3002<\/p>\n<p>#git branch -a<\/p>\n<p>\u6dfb\u52a0\u201c-a\u201c\u53c2\u6570\uff0c\u53ef\u4ee5\u540c\u65f6\u663e\u793a\u672c\u5730\u4ed3\u5e93\u548c\u8fdc\u7a0b\u4ed3\u5e93\u7684\u5206\u652f\u4fe1\u606f\u3002<\/p>\n<p>\u4e8c\u3001\u521b\u5efa\u3001\u5207\u6362\u5206\u652f<\/p>\n<p>#git checkout -b branchname<\/p>\n<p>\u521b\u5efa\u5e76\u5207\u6362\u5230\u65b0\u7684\u5206\u652fbranchname\u4e0b\uff0c\u4e0b\u5217\u4e24\u6761\u547d\u4ee4\u7684\u4f5c\u4e1a\u548c\u4e0a\u9762\u7684\u76f8\u540c\uff0c\u53ea\u662f\u5206\u6b65\u5b8c\u6210<\/p>\n<p>#git branch branchname<\/p>\n<p>#git checkout branchname<\/p>\n<p>\u8fd9\u4e24\u6b65\uff0c\u7b2c\u4e00\u6b65\u4e3a\u521b\u5efa\u5206\u652f\uff0c\u7b2c\u4e8c\u6b65\u4e3a\u5207\u6362\u5230\u5206\u652f\u3002<\/p>\n<p>\u4e09\u3001\u5206\u652f\u64cd\u4f5c<\/p>\n<p>\u5206\u652f\u8fdb\u884c\u6587\u4ef6\u4fee\u6539\uff0cgit add\uff0cgit commit\uff0c\u4e0d\u4f1a\u5f71\u54cd\u4e3b\u5206\u652f\u53ca\u5176\u5b83\u5206\u652f\u3002<\/p>\n<p>\u56db\u3001\u5207\u56de\u4e0a\u4e00\u5206\u652f<\/p>\n<p>#git chechkout -<\/p>\n<p>\u7528\u4e8e\u5207\u56de\u4e0a\u4e00\u5206\u652f\uff0c\u7c7b\u4f3c\u8fd4\u56de\u64cd\u4f5c<\/p>\n<p>\u4e94\u3001\u5408\u5e76\u5206\u652f<\/p>\n<p>#git merge --no-ff branchname<\/p>\n<p>\u5408\u5e76\u5206\u652f\u4e4b\u524d\u5148\u5207\u6362\u81f3\u4e3b\u5e72\u5206\u652f\u4e2d\uff0c\u6267\u884c\u547d\u4ee4\u540e\u4f1a\u8df3\u51fa\u7f16\u8f91\u5668\uff0c\u7f16\u8f91\u5668\u63d0\u793a\u8f93\u5165\u5408\u5e76\u4fe1\u606f\uff0c\u5176\u4e2d\u5305\u62ec\u4e00\u4e9b\u9ed8\u8ba4\u4fe1\u606f\uff0c\u9ed8\u8ba4\u4fdd\u5b58\u9000\u51fa\u4e5f\u53ef\u4ee5\uff0c\u76f4\u63a5\u5728\u4e0b\u9762\u6dfb\u52a0\u63cf\u8ff0\u6587\u5b57\u4e5f\u53ef\u4ee5\uff0c\u4e0d\u8981\u7528#\u5f00\u5173\uff0c\u76f4\u63a5\u5728\u6700\u4e0b\u9762\u6dfb\u52a0\u3002\u63cf\u8ff0\u4f1a\u8fdb\u5165log\u65e5\u5fd7\u3002<\/p>\n<p>--no-ff\u53c2\u6570\u662f\u963b\u6b62\u5feb\u8fdb\u5f0f\u5408\u5e76\uff0c\u4e0d\u52a0\u53c2\u6570\u4e5f\u53ef\u4ee5\u5408\u5e76\uff0c\u4f46\u6548\u679c\u7c7b\u4f3c\u4e8e\u76f4\u63a5\u6539\u53d8\u6307\u9488\uff0c\u5206\u652f\u7684\u63d0\u4ea4\u5386\u53f2\u4e5f\u4f1a\u5408\u5e76\u5230\u4e3b\u7ebf\u3002\u5efa\u8bae\u4f7f\u7528\u53c2\u6570\uff0c\u8fd9\u6837\u53ef\u4ee5\u4fdd\u6301\u4e24\u4e2a\u5206\u652f\u5404\u76f8\u5bf9\u72ec\u7acb\uff0c\u4e92\u4e0d\u5f71\u54cd\u3002\u3010<font color=\"#ff0000\">\u4e0d\u662f\u5f88\u7406\u89e3<\/font>\u3011<\/p>\n<p>\u5982\u679c\u591a\u4e2a\u5206\u652f\u4e00\u4e2a\u4e2a\u5408\u5e76\u81f3\u4e3b\u5206\u652f\uff0c\u4fee\u6539\u8fc7\u540c\u4e00\u4e2a\u6587\u4ef6\uff0c\u4f1a\u9020\u6210\u5408\u5e76\u51b2\u7a81\uff0c\u5408\u5e76\u7684\u7ed3\u679c\u662f\u51b2\u7a81\u6587\u4ef6\u4f1a\u628a\u4e24\u4e2a\u5206\u652f\u7684\u7ed3\u679c\u5408\u5e76\u5728\u4e00\u8d77\u5e76\u505a\u51fa\u6807\u8bb0\u201c=======\u201d\u4e0a\u4e0b\u90e8\u5206\u4e3a\u4e24\u4e2a\u5206\u652f\u7684\u90e8\u5206\uff0c\u624b\u52a8\u4fee\u6539\u540e\u518d\u6267\u884cgit add\u53cagit commit\u64cd\u4f5c\uff0c\u8fdb\u884c\u63d0\u4ea4\u3002<\/p>\n<p>\u516d\u3001<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0b\u8f7d\u5730\u5740\uff1ahttps:\/\/gi...<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[18],"class_list":["post-149","post","type-post","status-publish","format-standard","hentry","category-develop","tag-git"],"_links":{"self":[{"href":"https:\/\/www.ienter.com.cn\/blog\/wp-json\/wp\/v2\/posts\/149","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ienter.com.cn\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ienter.com.cn\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ienter.com.cn\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ienter.com.cn\/blog\/wp-json\/wp\/v2\/comments?post=149"}],"version-history":[{"count":0,"href":"https:\/\/www.ienter.com.cn\/blog\/wp-json\/wp\/v2\/posts\/149\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.ienter.com.cn\/blog\/wp-json\/wp\/v2\/media?parent=149"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ienter.com.cn\/blog\/wp-json\/wp\/v2\/categories?post=149"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ienter.com.cn\/blog\/wp-json\/wp\/v2\/tags?post=149"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}