{"id":856,"date":"2021-12-28T10:21:34","date_gmt":"2021-12-28T02:21:34","guid":{"rendered":"http:\/\/139.9.1.231\/?p=856"},"modified":"2022-06-29T20:10:12","modified_gmt":"2022-06-29T12:10:12","slug":"git","status":"publish","type":"post","link":"http:\/\/139.9.1.231\/index.php\/2021\/12\/28\/git\/","title":{"rendered":"\u5e38\u7528git\u547d\u4ee4\u6c47\u603b"},"content":{"rendered":"\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img src=\"https:\/\/cdn.pixabay.com\/photo\/2016\/02\/05\/13\/11\/fairy-tale-1180921_960_720.png\" alt=\"\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img src=\"https:\/\/www.ruanyifeng.com\/blogimg\/asset\/2015\/bg2015120901.png\" alt=\"\"\/><\/figure>\n\n\n\n<ul><li>Workspace\uff1a\u5de5\u4f5c\u533a<\/li><li>Index \/ Stage\uff1a\u6682\u5b58\u533a<\/li><li>Repository\uff1a\u4ed3\u5e93\u533a\uff08\u6216\u672c\u5730\u4ed3\u5e93\uff09<\/li><li>Remote\uff1a\u8fdc\u7a0b\u4ed3\u5e93<\/li><\/ul>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">git\u7f13\u5b58\u4fee\u6539\uff1a\u5982\u679c\u4f60\u6ca1\u6709\u6539\u5b8c\u8fd9\u4e2a\u5206\u652f\uff0c\u4e0d\u60f3\u63d0\u4ea4\uff0c\u4f46\u9700\u8981\u5207\u6362\u5230\u522b\u7684\u5206\u652f,\u4f7f\u7528\u6682\u5b58\uff1a<\/p>\n\n\n\n<p>git stash &#8211;include-untracked<\/p>\n\n\n\n<ul class=\"has-light-pink-background-color has-background\"><li>\u5728\u5176\u4ed6\u5206\u652f\u4e0a\u4fee\u6539\u5b8c\u4ee5\u540e\u518d\u5207\u56de\u4e4b\u524d\u7684feature\u5206\u652f\uff0c\u628a\u6682\u5b58\u7684\u4fee\u6539\u62ff\u51fa\u6765<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>git stash pop<\/code><\/pre>\n\n\n\n<h2>\u5982\u4f55\u5c06\u81ea\u5df1\u7684\u4ee3\u7801\u4e0a\u4f20\u5230git\u8fdc\u7a0b\u4ed3\u5e93\uff1a<\/h2>\n\n\n\n<ol><li>\u6253\u5f00&nbsp;Git Bash\u3002<\/li><li>\u5c06\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\u66f4\u6539\u4e3a\u60a8\u7684\u672c\u5730\u4ed3\u5e93\u3002<\/li><li>\u5c06\u8981\u63d0\u4ea4\u7684\u6587\u4ef6\u6682\u5b58\u5230\u672c\u5730\u4ed3\u5e93\u3002<code>$ git add . # Adds the file to your local repository and stages it for commit. \u8981\u53d6\u6d88\u6682\u5b58\u6587\u4ef6\uff0c\u8bf7\u4f7f\u7528 'git reset HEAD <em>YOUR-FILE<\/em>'\u3002<\/code><\/li><li>\u63d0\u4ea4\u6682\u5b58\u5728\u672c\u5730\u4ed3\u5e93\u4e2d\u7684\u6587\u4ef6\u3002<code>$ git commit -m \"Add existing file\" # Commits the tracked changes and prepares them to be pushed to a remote repository. \u8981\u5220\u9664\u6b64\u63d0\u4ea4\u5e76\u4fee\u6539\u6587\u4ef6\uff0c\u8bf7\u4f7f\u7528 'git reset --soft HEAD~1' \u5e76\u518d\u6b21\u63d0\u4ea4\u548c\u6dfb\u52a0\u6587\u4ef6\u3002<\/code><\/li><li><a href=\"https:\/\/docs.github.com\/cn\/github\/getting-started-with-github\/pushing-commits-to-a-remote-repository\">\u63a8\u9001\u66f4\u6539<\/a>\uff08\u672c\u5730\u4ed3\u5e93\u4e2d\uff09\u5230 GitHub.com\u3002<code>$ git push origin <em>your-branch<\/em><\/code><\/li><li>\u6ce8\u610f\u5982\u679chttps:\/\/github.com\/vina_MolecularDockingScript.git\u4e0d\u53ef\u4ee5\u7684\u8bdd\uff0c\u5c1d\u8bd5\u5c06 origin\u6539\u6210 git@github.com:\/vina_MolecularDockingScript.git<\/li><\/ol>\n\n\n\n<p class=\"has-light-pink-background-color has-background\"><strong>git \u6bd4\u8f83\u4e0d\u540c\u5206\u652f\u5dee\u5f02<\/strong><\/p>\n\n\n\n<p>git diff &nbsp;\u5206\u652f1 \u5206\u652f2&nbsp;&#8211;stat \uff08\u52a0\u4e0a &#8211;stat \u662f\u663e\u793a\u6587\u4ef6\u5217\u8868, \u9ed8\u8ba4\u662f\u6587\u4ef6\u5185\u5bb9diff\uff09<\/p>\n\n\n\n<p>git diff branch1 branch2 &#8211;stat&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; \/\/\u663e\u793a\u51fa\u6240\u6709\u6709\u5dee\u5f02\u7684\u6587\u4ef6\u5217\u8868<\/p>\n\n\n\n<p><br>git diff branch1 branch2 &nbsp;&nbsp;\u5177\u4f53\u6587\u4ef6\u8def\u5f84&nbsp;&nbsp; \/\/\u663e\u793a\u6307\u5b9a\u6587\u4ef6\u7684\u8be6\u7ec6\u5dee\u5f02<\/p>\n\n\n\n<p><br>git diff branch1 branch2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; \/\/\u663e\u793a\u51fa\u6240\u6709\u6709\u5dee\u5f02\u7684\u6587\u4ef6\u7684\u8be6\u7ec6\u5dee\u5f02<\/p>\n\n\n\n<p><strong>git diff \u88ab\u4fee\u6539\u7684\u6587\u4ef6\u540d    \u5c31\u53ef\u4ee5\u770b\u5230\u88ab\u4fee\u6539\u8fc7\u7684\u539f\u59cb\u5185\u5bb9<\/strong><\/p>\n\n\n\n<p><br>&nbsp;<\/p>\n\n\n\n<h2 class=\"has-light-pink-background-color has-background\">Git \u51fa\u73b0\uff01reject\u7684\u60c5\u51b5<\/h2>\n\n\n\n<p>\u89e3\u51b3\u529e\u6cd5\uff1a\u9996\u5148\u5c06\u672c\u5730\u4fee\u6539\u7684\u6587\u4ef6\u5907\u4efd\uff0c\u7136\u540e\u5f3a\u5236\u8ba9\u8fdc\u7a0b\u6587\u4ef6\u8986\u76d6\u672c\u5730\u4ed3\u5e93\u6587\u4ef6<\/p>\n\n\n\n<p>Git fetch \u2013all<\/p>\n\n\n\n<p>Git reset \u2013hard origin\/liangxianchen<\/p>\n\n\n\n<p>\u5f53\u5220\u9664\u672c\u5730\u6587\u4ef6\u540e\uff0c\u5982\u4f55\u4e0e\u8fdc\u7aef\u540c\u6b65\uff1f<\/p>\n\n\n\n<p>\u9996\u5148\u4e0d\u80fd\u76f4\u63a5\u5728\u672c\u5730\u6309del\u952e\u5220\u9664\uff0c\u8fd9\u6837\u5bf9\u8fdc\u7aef\u6ca1\u6709\u4efb\u4f55\u5f71\u54cd\uff0c\u5fc5\u987b\u4f7f\u7528git rm filename \u547d\u4ee4\u5220\u9664\uff0c\u5176\u6b21\uff0c\u5220\u9664\u5b8c\u4e4b\u540e\uff0cgit commit -m \u201cdelete filename\u201d \u4e00\u4e0b\uff0c\u6700\u540e git push\u5c31OK\u4e86<\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\"> \u5047\u8bbe\u6211\u4eec\u9700\u8981\u4ece\u8fdc\u7a0bpull\u4e0b\u4ee3\u7801\uff0c\u672c\u5730\u4fee\u6539\u540e\u5728\u4f20\u5230\u8fdc\u7a0b\u5b8c\u6574\u6d41\u7a0b\uff1a<\/p>\n\n\n\n<p>1\u3001\u672c\u5730\u65b0\u5efa\u6587\u4ef6\u5939\uff1atest\uff0c\u5e76\u5728test\u5185\u90e8\u6253\u5f00 git<\/p>\n\n\n\n<p>2\u3001\u8f93\u5165 git init \u521d\u59cb\u5316git\u4ed3\u5e93<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ git config --global user.name \"runoob\"\n$ git config --global user.email test@runoob.com<\/pre>\n\n\n\n<p>3\u3001\u8f93\u5165<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">git pull &lt;\u8fdc\u7a0b\u4e3b\u673a\u540d&gt; &lt;\u8fdc\u7a0b\u5206\u652f\u540d&gt;:&lt;\u672c\u5730\u5206\u652f\u540d&gt;<\/pre>\n\n\n\n<p>\u6bd4\u5982\uff1agit pull git@10.112.55.138:CNN\/code.git  master:liangxianchen<\/p>\n\n\n\n<p>\u628a\u6211\u7684\u8fdc\u7a0b\u5206\u652fmaster\u62c9\u5230\u4e86\u672c\u5730 liangxianchen \u5206\u652f<\/p>\n\n\n\n<p>4\u3001git branch -a \u67e5\u770b\u672c\u5730\u548c\u8fdc\u7a0b\u5206\u652f<\/p>\n\n\n\n<p>5\u3001\u6b64\u65f6\u672c\u5730\u5df2\u7ecf\u6709\u4e86\u8fdc\u7a0b\u5206\u652f\u4ee3\u7801\uff0c\u53ef\u4ee5\u5728\u672c\u5730\u5bf9\u4ee3\u7801\u8fdb\u884c\u4fee\u6539\u548c\u589e\u52a0\u5220\u9664<\/p>\n\n\n\n<p>\u4fee\u6539\u5b8c\u6210\u540e\uff1a<\/p>\n\n\n\n<p>\u9996\u5148\u4e00\u5b9a\u8981\u5148\u62c9\u53d6\u8fdc\u7a0b\u5206\u652f\uff01\uff01\uff01\uff01\uff1a<\/p>\n\n\n\n<p> \u6bd4\u5982\uff1agit pull git@10.112.55.138:CNN\/code.git  master: liangxianchen  <\/p>\n\n\n\n<p>\u7136\u540e\uff1agit add .<\/p>\n\n\n\n<p>git commit -m &#8220;\u63d0\u4ea4\u7684\u5907\u6ce8\u4fe1\u606f&#8221;<\/p>\n\n\n\n<p>git push git@10.112.55.138:CNN\/code.git  liangxianchen :liangxianchen<\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">\u5982\u679c\u60f3\u8981 \u5c06liangxianchen\u5206\u652f\u5408\u5e76\u5230master\u5206\u652f\uff1a<\/p>\n\n\n\n<p>\u73b0\u5728\u672c\u5730\u5c06\u4e24\u4e2a\u5206\u652f\u5408\u5e76\uff0c\u5728\u4f7f\u7528<\/p>\n\n\n\n<p> git push git@10.112.55.138:CNN\/code.git  master:master<\/p>\n\n\n\n<p>\u6ce8\uff1agit \u8fd8\u53ef\u4ee5\u6307\u5b9a\u67d0\u4e9b\u6587\u4ef6\u4e0d\u53c2\u4e0egit\u63d0\u4ea4\uff1agitignore\uff0c\u6211\u4eec\u5728git\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a.gitignore\u6587\u4ef6\uff0c\u7136\u540e\u5728\u8fd9\u4e2a\u6587\u4ef6\u5f53\u4e2d\u5217\u4e3e\u51fa\u6211\u4eec\u4e0d\u5e0c\u671b\u63d0\u4ea4\u7684\u6587\u4ef6\u5373\u53ef\u3002<\/p>\n\n\n\n<p>\u51e1\u662f\u5217\u5728\u8fd9\u4e2a\u6587\u4ef6\u5f53\u4e2d\u7684\u540d\u79f0\uff0c\u5f53\u6211\u4eec\u5728\u4f7f\u7528git add\u7684\u65f6\u5019\u90fd\u4f1a\u66ff\u6211\u4eec\u5ffd\u7565\u6389\u3002\u6211\u4eec\u4e5f\u6ca1\u6709\u5fc5\u8981\u4ece\u5934\u5f00\u59cb\u7f16\u5199\u8fd9\u4e2agitignore\u6587\u4ef6\uff0c\u56e0\u4e3agit\u5f53\u4e2d\u5df2\u7ecf\u66ff\u6211\u4eec\u5199\u597d\u4e86\u5f88\u591a\u6a21\u677f\uff0c\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u62ff\u8fc7\u6765\u53c2\u8003\u3002<\/p>\n\n\n\n<p>\u6a21\u677f\u7684\u5730\u5740\uff1ahttps:\/\/github.com\/github\/gitignore<\/p>\n\n\n\n<p>\u4e00\u822c\u6765\u8bf4\uff0c\u9879\u76ee\u7684log\u6587\u4ef6\u4e0d\u9700\u8981\u4f20\u8f93\uff0c\u653e\u5230ignore\u4e2d<\/p>\n\n\n\n<p>git branch liangxianchen  \u65b0\u5efa\u5206\u652f<\/p>\n\n\n\n<p>git checkout liangxianchen  \u5207\u6362\u5206\u652f<\/p>\n\n\n\n<h1><a href=\"https:\/\/www.cnblogs.com\/lowmanisbusy\/p\/9054087.html\">git \u4f7f\u7528merge \u5bf9\u672c\u5730\u5206\u652f\u8fdb\u884c\u5408\u5e76 \u5e76\u8fdb\u884c\u4ee3\u7801\u63d0\u4ea4\u7684\u6d41\u7a0b<\/a><\/h1>\n\n\n\n<p>1\u3001\u4e3a\u5565\u9700\u8981git\u521b\u5efa\u5206\u652f\uff1a<\/p>\n\n\n\n<p>      \u5bf9\u4e8e\u672c\u5730\u6765\u8bf4\uff0c\u5176\u5b9e\u4e00\u4e2a\u5206\u652f\u662f\u8db3\u591f\u7684\uff0c\u4f46\u5047\u5982\u4f60\u76ee\u524d\u6b63\u5728\u4fee\u6539\u6574\u4e2a\u9879\u76ee\u7684partA\uff0c\u8fd8\u6ca1\u4fee\u6539\u5b8c\uff0c\u8001\u677f\u8ba9\u4f60\u4eca\u5929\u52a0\u4e2a\u73ed\uff0c\u628apartB\u6539\u4e00\u4e0b\u7136\u540e\u63d0\u4ea4\u4e0a\u53bb\uff0c\u8fd9\u65f6\u5019\u5c31\u9700\u8981\u5206\u652f\u4e86\uff0c\u4f60\u53ef\u4ee5\u5207\u6362\u4e0d\u540c\u7684\u5206\u652f\u53bb\u5b8c\u6210\u4e0d\u540c\u7684\u5de5\u4f5c\uff0c\u8fd9\u6837\u7684\u5316\uff0c\u4f60\u53ea\u9700\u8981\u628apartB\u7684\u5206\u652f\u63a8\u4e0a\u53bb\u3002\u5982\u679c\u4f60\u53ea\u6709\u4e00\u4e2a\u5206\u652f\uff0c\u90a3\u63a8\u4e0a\u53bb\u7684\u5c31\u662f\u6240\u6709\u7684\u4fee\u6539\u3002<\/p>\n\n\n\n<p>\u7b2c\u4e8c\u79cd\u60c5\u51b5\uff1a\u5982\u679c\u4f60\u9700\u8981\u53bb\u4e34\u65f6\u4fee\u6539\u4e00\u90e8\u5206\u5185\u5bb9\uff0c\u53ef\u4ee5\u65b0\u5efa\u5206\u652f\uff0c\u5728\u8be5\u5206\u652f\u4fee\u6539\uff0c\u4fee\u6539\u5b8c\u6210\uff0c\u5728\u5207\u6362\u56de\u4e3b\u5206\u652f\uff0c\u7ee7\u7eed\u4e4b\u524d\u7684\u5de5\u4f5c\u3002<\/p>\n\n\n\n<p>1.\u53ea\u6709\u5f53\u5c06\u4fee\u6539\u5185\u5bb9commit\u540e \u8be5\u4fee\u6539\u624d\u5b8c\u5168\u751f\u6548,\u8fdb\u884cmerge\u524d\u9700\u8981\u5c06\u4e24\u4e2a\u5206\u652f\u4fee\u6539\u7684\u5185\u5bb9\u90fd\u8fdb\u884ccommit<\/p>\n\n\n\n<p>2.\u5047\u8bbe\u672c\u5730\u4e24\u4e2a\u5206\u652f&nbsp; &nbsp;\u7528\u4e8e\u5f00\u53d1\u7684\u5206\u652f:dev&nbsp; &nbsp; \u7528\u4e8e\u540c\u6b65\u8fdc\u7a0b\u4ed3\u5e93\u7684\u5206\u652f:master&nbsp;<\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">3\u3001<strong>\u6211\u8981\u540c\u65f6\u5f00\u53d1\u51e0\u4e2a\u529f\u80fd<\/strong><\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">3.\u5207\u6362\u5230master\u5206\u652f \u8fdb\u884c (git pull origin \u8fdc\u7a0b\u5206\u652f) \u4e0d\u8981\u5728master \u5206\u652f\u8fdb\u884c\u5f00\u53d1(\u4e5f\u4e0d\u8981\u5728master\u5206\u652f\u8fdb\u884cadd commit),\u4ee5\u6b64\u4fdd\u8bc1\u5f53\u5728master\u5206\u652f\u8fdb\u884cgit pull \u4e0d\u4f1a\u4ea7\u751f\u51b2\u7a81(\u5982\u679c\u4e0d\u614e\u5728master\u5206\u652f\u4fee\u6539\u4e86\u5185\u5bb9, \u53ef\u4ee5\u5148\u64a4\u9500\u6240\u6709\u4fee\u6539,\u518d\u5c06\u7248\u672c\u56de\u9000\u5230\u6ca1\u6709\u51b2\u7a81\u7684\u5730\u65b9)<\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">4.\u5728master\u5206\u652f\u62c9\u53d6\u4e86\u6700\u65b0\u4ee3\u7801\u540e,\u5982\u679c\u6ca1\u6709\u5728master\u5206\u652f\u8fdb\u884c\u8fc7\u5f00\u53d1,\u90a3\u4e48\u8fd9\u4e2a\u5206\u652f\u5185\u5bb9\u5c31\u662f\u6ca1\u6709\u51b2\u7a81\u7684\u6700\u65b0\u7684\u5185\u5bb9<\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">5.\u5207\u6362\u5230dev\u5206\u652f, \u5c06\u6240\u6709\u7684\u4fee\u6539\u8fdb\u884cadd \u4ee5\u53cacommit <\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\"><code>dev<\/code>\u5206\u652f\u7684\u5de5\u4f5c\u5b8c\u6210\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u5207\u6362\u56de<code>master<\/code>\u5206\u652f\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ git checkout master\nSwitched to branch 'master'\n<\/code><\/pre>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">\u5207\u6362\u56de<code>master<\/code>\u5206\u652f\u540e\uff0c\u518d\u67e5\u770b\u4e00\u4e2a<code>readme.txt<\/code>\u6587\u4ef6\uff0c\u521a\u624d\u6dfb\u52a0\u7684\u5185\u5bb9\u4e0d\u89c1\u4e86\uff01\u56e0\u4e3a\u90a3\u4e2a\u63d0\u4ea4\u662f\u5728<code>dev<\/code>\u5206\u652f\u4e0a\uff0c\u800c<code>master<\/code>\u5206\u652f\u6b64\u523b\u7684\u63d0\u4ea4\u70b9\u5e76\u6ca1\u6709\u53d8<\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">\u628a<code>dev<\/code>\u5206\u652f\u7684\u5de5\u4f5c\u6210\u679c\u5408\u5e76\u5230<code>master<\/code>\u5206\u652f\u4e0a   <code>git merge<\/code>\u547d\u4ee4\u7528\u4e8e\u5408\u5e76\u6307\u5b9a\u5206\u652f\u5230\u5f53\u524d\u5206\u652f \uff1a <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git merge dev\uff08\u5206\u652f\u540d\uff09\n\n<strong>\u5408\u5e76\u5b8c\u6210\u540e\uff0c\u5c31\u53ef\u4ee5\u653e\u5fc3\u5730\u5220\u9664dev\u5206\u652f\u4e86\uff1a<\/strong>\n\n$ git branch -d dev<\/code><\/pre>\n\n\n\n<ul><li>merge \u9047\u89c1\u51b2\u7a81\u540e\u4f1a\u76f4\u63a5\u505c\u6b62\uff0c\u7b49\u5f85\u624b\u52a8\u89e3\u51b3\u51b2\u7a81\u5e76\u91cd\u65b0\u63d0\u4ea4 commit \u540e\uff0c\u624d\u80fd\u518d\u6b21 merge<\/li><li>merge \u662f\u4e00\u4e2a\u5408\u5e76\u64cd\u4f5c\uff0c\u4f1a\u5c06\u4e24\u4e2a\u5206\u652f\u7684\u4fee\u6539\u5408\u5e76\u5728\u4e00\u8d77\uff0c\u9ed8\u8ba4\u64cd\u4f5c\u7684\u60c5\u51b5\u4e0b\u4f1a\u63d0\u4ea4\u5408\u5e76\u4e2d\u4fee\u6539\u7684\u5185\u5bb9<\/li><\/ul>\n\n\n\n<p>\u4e8c\u3001\u5047\u8bbe\u8fdc\u7a0b\u4ed3\u5e93\u53ea\u6709mater\u5206\u652f<\/p>\n\n\n\n<p>1. \u514b\u9686\u4ee3\u7801<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git clone https:\/\/github.com\/master-dev.git  \n# \u8fd9\u4e2agit\u8def\u5f84\u662f\u65e0\u6548\u7684\uff0c\u793a\u4f8b\u800c\u5df2<\/code><\/pre>\n\n\n\n<p>2. \u67e5\u770b\u6240\u6709\u5206\u652f<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git branch --all  \n# \u9ed8\u8ba4\u53ea\u6709master\u5206\u652f\uff0c\u6240\u4ee5\u4f1a\u770b\u5230\u5982\u4e0b\u4e24\u4e2a\u5206\u652f\n# master&#091;\u672c\u5730\u4e3b\u5206\u652f] origin\/master&#091;\u8fdc\u7a0b\u4e3b\u5206\u652f]\n# \u65b0\u514b\u9686\u4e0b\u6765\u7684\u4ee3\u7801\u9ed8\u8ba4master\u548corigin\/master\u662f\u5173\u8054\u7684\uff0c\u4e5f\u5c31\u662f\u4ed6\u4eec\u7684\u4ee3\u7801\u4fdd\u6301\u540c\u6b65<\/code><\/pre>\n\n\n\n<p>3. \u521b\u5efa\u672c\u5730\u65b0\u7684dev\u5206\u652f<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git branch dev  # \u521b\u5efa\u672c\u5730\u5206\u652f\ngit branch  # \u67e5\u770b\u5206\u652f\n# \u8fd9\u662f\u4f1a\u770b\u5230master\u548cdev\uff0c\u800c\u4e14master\u4e0a\u4f1a\u6709\u4e00\u4e2a\u661f\u53f7\n# \u8fd9\u4e2a\u65f6\u5019dev\u662f\u4e00\u4e2a\u672c\u5730\u5206\u652f\uff0c\u8fdc\u7a0b\u4ed3\u5e93\u4e0d\u77e5\u9053\u5b83\u7684\u5b58\u5728\n# \u672c\u5730\u5206\u652f\u53ef\u4ee5\u4e0d\u540c\u6b65\u5230\u8fdc\u7a0b\u4ed3\u5e93\uff0c\u6211\u4eec\u53ef\u4ee5\u5728dev\u5f00\u53d1\uff0c\u7136\u540emerge\u5230master\uff0c\u4f7f\u7528master\u540c\u6b65\u4ee3\u7801\uff0c\u5f53\u7136\u4e5f\u53ef\u4ee5\u540c\u6b65<\/code><\/pre>\n\n\n\n<p>4. \u53d1\u5e03dev\u5206\u652f<\/p>\n\n\n\n<p>\u53d1\u5e03dev\u5206\u652f\u6307\u7684\u662f\u540c\u6b65dev\u5206\u652f\u7684\u4ee3\u7801\u5230\u8fdc\u7a0b\u670d\u52a1\u5668<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git push origin dev:dev  # \u8fd9\u6837\u8fdc\u7a0b\u4ed3\u5e93\u4e5f\u6709\u4e00\u4e2adev\u5206\u652f\u4e86<\/code><\/pre>\n\n\n\n<p>5. \u5728dev\u5206\u652f\u5f00\u53d1\u4ee3\u7801<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git checkout dev  # \u5207\u6362\u5230dev\u5206\u652f\u8fdb\u884c\u5f00\u53d1\n# \u5f00\u53d1\u4ee3\u7801\u4e4b\u540e\uff0c\u6211\u4eec\u6709\u4e24\u4e2a\u9009\u62e9\n# \u7b2c\u4e00\u4e2a\uff1a\u5982\u679c\u529f\u80fd\u5f00\u53d1\u5b8c\u6210\u4e86\uff0c\u53ef\u4ee5\u5408\u5e76\u4e3b\u5206\u652f\ngit checkout master  # \u5207\u6362\u5230\u4e3b\u5206\u652f\ngit merge dev  # \u628adev\u5206\u652f\u7684\u66f4\u6539\u548cmaster\u5408\u5e76\ngit push  # \u63d0\u4ea4\u4e3b\u5206\u652f\u4ee3\u7801\u8fdc\u7a0b\ngit checkout dev  # \u5207\u6362\u5230dev\u8fdc\u7a0b\u5206\u652f\ngit push  # \u63d0\u4ea4dev\u5206\u652f\u5230\u8fdc\u7a0b\n# \u7b2c\u4e8c\u4e2a\uff1a\u5982\u679c\u529f\u80fd\u6ca1\u6709\u5b8c\u6210\uff0c\u53ef\u4ee5\u76f4\u63a5\u63a8\u9001\ngit push  # \u63d0\u4ea4\u5230dev\u8fdc\u7a0b\u5206\u652f\n# \u6ce8\u610f\uff1a\u5728\u5206\u652f\u5207\u6362\u4e4b\u524d\u6700\u597d\u5148commit\u5168\u90e8\u7684\u6539\u53d8\uff0c\u9664\u975e\u4f60\u771f\u7684\u77e5\u9053\u81ea\u5df1\u5728\u505a\u4ec0\u4e48<\/code><\/pre>\n\n\n\n<p>6. \u5220\u9664\u5206\u652f<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git push origin :dev  # \u5220\u9664\u8fdc\u7a0bdev\u5206\u652f\uff0c\u5371\u9669\u547d\u4ee4\u54e6\n# \u4e0b\u9762\u4e24\u6761\u662f\u5220\u9664\u672c\u5730\u5206\u652f\ngit checkout master  # \u5207\u6362\u5230master\u5206\u652f\ngit branch -d dev  # \u5220\u9664\u672c\u5730dev\u5206\u652f<\/code><\/pre>\n\n\n\n<h2 class=\"has-light-pink-background-color has-background\">git\u53d6\u6d88Commit\uff0c\u53d6\u6d88add\uff0c\u56de\u6eda\u4ee3\u7801<\/h2>\n\n\n\n<p>git commit\u4e4b\u540e\u53d6\u6d88\u7684\u64cd\u4f5c\u4f7f\u7528reset\u6307\u4ee4\u8fdb\u884c\u3002 1.git reset &#8211;soft HEAD^\uff0c\u64a4\u9500commit\uff0c\u4f46\u662f\u4e0d\u64a4\u9500add\u52a8\u4f5c\u3002 2.git reset &#8211;hard HEAD^\uff0c\u64a4\u9500commit\uff0c\u5e76\u4e14\u64a4\u9500add\u52a8\u4f5c\u3002 3.git reset HEAD &lt;\u6587\u4ef6\u540d&gt;\uff0c\u64a4\u56deadd\u52a8\u4f5c\u3002 4.git checkout .\uff0c\u4e22\u5f03\u672c\u6b21\u4fee\u6539\u5185\u5bb9\uff08<strong>\u6587\u4ef6\u88ab\u4fee\u6539\u4e86\uff0c\u4f46\u672a\u6267\u884c<code>git add<\/code>\u64cd\u4f5c<\/strong>\uff09<\/p>\n\n\n\n<p>git reset HEAD filename  \u53d6\u6d88\u67d0\u4e2a\u6587\u4ef6\u7684add<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>git fetch<\/strong><\/p>\n\n\n\n<p>\u4f7f\u7528 git fetch \u6307\u4ee4\u5c06\u8fdc\u7a0b\u5206\u652f\u4e0a\u7684\u6700\u65b0\u7684\u4fee\u6539\u4e0b\u8f7d\u4e0b\u6765\u3002<\/p>\n\n\n\n<p>&lt;div&gt;&lt;br class=&#8221;Apple-interchange-newline&#8221;&gt;git merge&lt;\/div&gt;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">git fetch upstream<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">git merge upstream\/master<\/pre>\n\n\n\n<p>pull=fetch+merge\uff0cpull\u7684\u8bdd\uff0c\u4e0b\u62c9\u8fdc\u7a0b\u5206\u652f\u5e76\u4e0e\u672c\u5730\u5206\u652f\u5408\u5e76\u3002fetch\u53ea\u662f\u4e0b\u62c9\u8fdc\u7a0b\u5206\u652f\uff0c\u600e\u4e48\u5408\u5e76\uff0c\u53ef\u4ee5\u81ea\u5df1\u518d\u505a\u9009\u62e9\u3002<\/p>\n\n\n\n<p><strong>git pull<\/strong><\/p>\n\n\n\n<p>git pull \u6307\u4ee4\u5b9e\u9645\u505a\u4e86\u4e24\u4ef6\u4e8b\uff1agit fetch \u548c git merge\u3002<\/p>\n\n\n\n<h1>\u5c06\u5206\u652f\u4ee3\u7801\u62c9\u53d6\u5230\u672c\u5730,\u4fee\u6539\u540e\u5982\u4f55\u4e0a\u4f20\u5230git\u5206\u652f<\/h1>\n\n\n\n<p>\u5982\u679c\u662f\u591a\u4eba\u5408\u4f5c\uff0c\u63a8\u9001\u4e4b\u524d\u6700\u597d\u5148\u66f4\u65b0\u4e00\u904d\u4ee3\u7801\uff0c\u56e0\u4e3a\u53ef\u80fd\u522b\u4eba\u66f4\u65b0\u8fc7\u8be5\u5206\u652f\uff0c\u9632\u6b62\u8986\u76d6\u522b\u4eba\u66f4\u65b0\u540e\u7684\u4ee3\u7801\u3002\u5c06\u6700\u65b0\u7684\u5206\u652f\u4ee3\u7801\u62c9\u53d6\u5230\u672c\u5730\u540e\uff0c\u518d\u8fdb\u884c\u63d0\u4ea4<\/p>\n\n\n\n<h2>1. \u521b\u5efa\u6587\u4ef6\u5939\u5e76\u521d\u59cb\u5316\u672c\u5730\u4ed3\u5e93<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>mkdir test\ncd test\ngit init\n<\/code><\/pre>\n\n\n\n<h2>\u5173\u8054\u672c\u5730\u4ed3\u5e93\u548c\u8fdc\u7a0b\u4ed3\u5e93<\/h2>\n\n\n\n<p>git remote add origin git@github.com:liqiangyz\/learngit.git<\/p>\n\n\n\n<p>\u8bf4\u660e\uff1a<\/p>\n\n\n\n<ul><li>origin\u8868\u793a\u8fdc\u7a0b\u5e93\u7684\u540d\u5b57\uff0c\u53ef\u4ee5\u968f\u610f\uff0c\u4e00\u822c\u9ed8\u8ba4\u4e3aorigin\uff1b<\/li><li>origin\u540e\u9762\u8868\u793a\u8fdc\u7a0b\u4ed3\u5e93\u7684\u771f\u5b9e\u5730\u5740\uff0c\u5982\u4e0b\u56fe\u6240\u793a\u3002\u6211\u8fd9\u91cc\u4f7f\u7528\u7684\u662fSSH\u5730\u5740\uff0c\u5f53\u7136\u4e5f\u53ef\u4ee5\u4f7f\u7528HTTPS\u5730\u5740\uff0c\u590d\u5236\u8fc7\u6765\u5c31\u884c\u3002<\/li><\/ul>\n\n\n\n<h2><strong>git remote \u5220\u9664\u5df2\u6dfb\u52a0\u7684\u8fdc\u7a0b\u4ed3\u5e93\u5730\u5740<\/strong><\/h2>\n\n\n\n<p>\u6dfb\u52a0\u8fdc\u7a0b\u4ed3\u5e93\u51fa\u9519\uff0c\u56e0\u4e3a\u5df2\u7ecf\u5b58\u5728\u4e86\u4e00\u4e2a\u9519\u8bef\u7684\u5730\u5740<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"1000\" height=\"173\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-71.png\" alt=\"\" class=\"wp-image-4463\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-71.png 1000w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-71-300x52.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/05\/image-71-768x133.png 768w\" sizes=\"(max-width: 1000px) 100vw, 1000px\" \/><\/figure>\n\n\n\n<p>\u67e5\u770b\u5f53\u524d\u914d\u7f6e\u7684\u8fdc\u7a0b\u4ed3\u5e93\u5730\u5740\uff1a<\/p>\n\n\n\n<p>git remote -v<\/p>\n\n\n\n<p>\u5220\u9664\u672c\u5730\u6307\u5b9a\u7684\u8fdc\u7a0b\u5730\u5740\uff1a<\/p>\n\n\n\n<p>git remote remove origin<br>\u518d\u6267\u884c-v\u7684\u67e5\u770b\uff0c\u53ef\u4ee5\u6dfb\u52a0\u65b0\u7684\u8fdc\u7a0b\u4ed3\u5e93\u5730\u5740\u4e86<\/p>\n\n\n\n<h2>3. \u62c9\u53d6\u5206\u652f\u4ee3\u7801<\/h2>\n\n\n\n<p><code>git fetch<\/code>\u662f\u5c06\u8fdc\u7a0b\u4e3b\u673a\u7684\u6700\u65b0\u5185\u5bb9\u62c9\u5230\u672c\u5730\uff0c\u7528\u6237\u5728\u68c0\u67e5\u4e86\u4ee5\u540e\u51b3\u5b9a\u662f\u5426\u5408\u5e76\u5230\u5de5\u4f5c\u672c\u673a\u5206\u652f\u4e2d\u3002<\/p>\n\n\n\n<p>\u800c<code>git pull<\/code> \u5219\u662f\u5c06\u8fdc\u7a0b\u4e3b\u673a\u7684\u6700\u65b0\u5185\u5bb9\u62c9\u4e0b\u6765\u540e\u76f4\u63a5\u5408\u5e76\uff0c\u5373\uff1a<code>git pull = git fetch + git merge\uff0c\u8fd9\u6837\u53ef\u80fd\u4f1a\u4ea7\u751f\u51b2\u7a81\uff0c\u9700\u8981\u624b\u52a8\u89e3\u51b3\u3002<br><\/code><\/p>\n\n\n\n<p>git fetch origin develop <em>#\u53ef\u4ee5\u4f7f\u7528git fetch origin \u62c9\u53d6\u5168\u90e8<\/em><\/p>\n\n\n\n<p>\u8bf4\u660e\uff1a<\/p>\n\n\n\n<ul><li>develop\u4e3a\u6211\u7684\u5206\u652f\u540d\u5b57\uff0c\u6839\u636e\u81ea\u5df1\u7684\u5206\u652f\u51b3\u5b9a\u3002<\/li><li>\u6709\u7684\u540c\u5b66\u53ef\u80fd\u4f1a\u7528git pull\uff0cgit pull = git fetch + git merge\uff0c\u56e0\u4e3apull\u62c9\u53d6\u4f1a\u5408\u5e76\u672c\u5730\u6587\u4ef6\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u51b2\u7a81\u3002<\/li><\/ul>\n\n\n\n<h2>4. \u521b\u5efa\u672c\u5730\u5206\u652f\uff0c\u5e76\u5207\u6362\u5230\u672c\u5730\u5206\u652f<\/h2>\n\n\n\n<p>\u7ecf\u8fc7\u4e0a\u4e00\u6b65\uff0c\u5728\u672c\u5730\u8fd8\u770b\u4e0d\u5230\u62c9\u53d6\u7684\u4ee3\u7801\uff0c\u9700\u8981\u624b\u52a8\u521b\u5efa\u4e00\u4e0b\uff1a<\/p>\n\n\n\n<p>\u4e0d\u8981\u4f7f\u7528git checkout -b develop\uff0c\u5982\u679c\u6ca1\u6709\u5173\u8054\u8fdc\u7a0b\uff0c\u4f1a\u51fa\u95ee\u9898\uff01\uff01\uff01<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git checkout -b develop origin\/develop\n<\/code><\/pre>\n\n\n\n<p>\u8bf4\u660e\uff1a<\/p>\n\n\n\n<p>git checkout\u8868\u793a\u5207\u6362\u5206\u652f\u6216\u6062\u590d\u5de5\u4f5c\u6811\u6587\u4ef6\u3002<br>-b\u8868\u793a\u8fdb\u5165git checkout\u4e4b\u524d\u6267\u884cgit branch \u521b\u5efa\u5206\u652f\u64cd\u4f5c\u3002<br>\u7efc\u5408\u8d77\u6765\u8003\u8651\uff0c\u8fd9\u4e00\u6b65\u7684\u64cd\u4f5c\u76f8\u5f53\u4e8e\u6267\u884ccheckout\u547d\u4ee4\u68c0\u51fa\u8fdc\u7a0b\u62c9\u53d6\u5206\u652f\uff0c\u5e76\u8fdb\u5165\u8be5\u5206\u652f\u3002<br>\u4f7f\u7528ls\u547d\u4ee4\u53ef\u4ee5\u770b\u5230\u4e0b\u62c9\u7684\u6587\u4ef6\uff0c\u5e76\u4e14\u4f7f\u7528git branch\u547d\u4ee4\u53ef\u4ee5\u770b\u5230\u5f53\u524d\u505c\u7559\u7684\u5206\u652f<br><\/p>\n\n\n\n<h2>5. \u66f4\u65b0\u5206\u652f\u4ee3\u7801<\/h2>\n\n\n\n<p>\u5982\u679c\u8fdc\u7a0b\u5206\u652f\u4e0a\u6709\u66f4\u65b0\uff0c\u53ef\u4ee5\u4f7f\u7528pull\u547d\u4ee4\u5bf9\u672c\u5730\u8fdb\u884c\u66f4\u65b0\uff0c\u5982\u679c\u6ca1\u6709\uff0c\u5219\u53ef\u4ee5\u8df3\u8fc7\u6b64\u6b65\u9aa4\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git pull origin develop\uff08\u5206\u652f\uff09<\/code><\/pre>\n\n\n\n<p>1\u3001\u67e5\u770b\u6587\u4ef6\u72b6\u6001<\/p>\n\n\n\n<p>git status<br>2\u3001\u6dfb\u52a0\u5168\u90e8\u6587\u4ef6\u5230\u6682\u5b58\u533a<\/p>\n\n\n\n<p>git add .<br><br>3\u3001\u5c06\u6682\u5b58\u533a\u5185\u5bb9\u6dfb\u52a0\u5230\u672c\u5730\u4ed3\u5e93\u4e2d<\/p>\n\n\n\n<p>git commit -m &#8220;cpp&#8221;<\/p>\n\n\n\n<h2>6\u3001\u63a8\u9001(push)\u672c\u5730\u5206\u652f\u5230\u8fdc\u7a0b\u5206\u652f<\/h2>\n\n\n\n<p><strong>\u63a8\u9001\u4e4b\u524d\u6700\u597d\u5148\u66f4\u65b0\u4e00\u904d\u4ee3\u7801\uff01\u9632\u6b62\u8986\u76d6\uff01\uff01\uff01\u81ea\u5df1\u53bb\u7406\u89e3\u4e00\u4e0b\u54c8\u3002<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git pull origin develop\ngit push origin develop<\/code><\/pre>\n\n\n\n<h2>\u4e00\u3001\u65b0\u5efa\u4ee3\u7801\u5e93<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>\n# \u5728\u5f53\u524d\u76ee\u5f55\u65b0\u5efa\u4e00\u4e2aGit\u4ee3\u7801\u5e93\n$ git init\n\n# \u65b0\u5efa\u4e00\u4e2a\u76ee\u5f55\uff0c\u5c06\u5176\u521d\u59cb\u5316\u4e3aGit\u4ee3\u7801\u5e93\n$ git init &#091;project-name]\n\n# \u4e0b\u8f7d\u4e00\u4e2a\u9879\u76ee\u548c\u5b83\u7684\u6574\u4e2a\u4ee3\u7801\u5386\u53f2\n$ git clone &#091;url]\n<\/code><\/pre>\n\n\n\n<h2>\u4e8c\u3001\u914d\u7f6e<\/h2>\n\n\n\n<p>Git\u7684\u8bbe\u7f6e\u6587\u4ef6\u4e3a<code>.gitconfig<\/code>\uff0c\u5b83\u53ef\u4ee5\u5728\u7528\u6237\u4e3b\u76ee\u5f55\u4e0b\uff08\u5168\u5c40\u914d\u7f6e\uff09\uff0c\u4e5f\u53ef\u4ee5\u5728\u9879\u76ee\u76ee\u5f55\u4e0b\uff08\u9879\u76ee\u914d\u7f6e\uff09\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n# \u663e\u793a\u5f53\u524d\u7684Git\u914d\u7f6e\n$ git config --list\n\n# \u7f16\u8f91Git\u914d\u7f6e\u6587\u4ef6\n$ git config -e &#091;--global]\n\n# \u8bbe\u7f6e\u63d0\u4ea4\u4ee3\u7801\u65f6\u7684\u7528\u6237\u4fe1\u606f\n$ git config &#091;--global] user.name \"&#091;name]\"\n$ git config &#091;--global] user.email \"&#091;email address]\"\n<\/code><\/pre>\n\n\n\n<h2>\u4e09\u3001\u589e\u52a0\/\u5220\u9664\u6587\u4ef6<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>\n# \u6dfb\u52a0\u6307\u5b9a\u6587\u4ef6\u5230\u6682\u5b58\u533a\n$ git add &#091;file1] &#091;file2] ...\n\n# \u6dfb\u52a0\u6307\u5b9a\u76ee\u5f55\u5230\u6682\u5b58\u533a\uff0c\u5305\u62ec\u5b50\u76ee\u5f55\n$ git add &#091;dir]\n\n# \u6dfb\u52a0\u5f53\u524d\u76ee\u5f55\u7684\u6240\u6709\u6587\u4ef6\u5230\u6682\u5b58\u533a\n$ git add .\n\n<strong>git add -u \uff1a\u5c06\u6587\u4ef6\u7684\u4fee\u6539\u3001\u6587\u4ef6\u7684\u5220\u9664\uff0c\u6dfb\u52a0\u5230\u6682\u5b58\u533a\u3002<\/strong>\n<strong>\ngit add . \uff1a\u5c06\u6587\u4ef6\u7684\u4fee\u6539\uff0c\u6587\u4ef6\u7684\u65b0\u5efa\uff0c\u6dfb\u52a0\u5230\u6682\u5b58\u533a\u3002<\/strong>\n<strong>\ngit add -A \uff1a\u5c06\u6587\u4ef6\u7684\u4fee\u6539\uff0c\u6587\u4ef6\u7684\u5220\u9664\uff0c\u6587\u4ef6\u7684\u65b0\u5efa\uff0c\u6dfb\u52a0\u5230\u6682\u5b58\u533a\u3002<\/strong>\n\n# \u6dfb\u52a0\u6bcf\u4e2a\u53d8\u5316\u524d\uff0c\u90fd\u4f1a\u8981\u6c42\u786e\u8ba4\n# \u5bf9\u4e8e\u540c\u4e00\u4e2a\u6587\u4ef6\u7684\u591a\u5904\u53d8\u5316\uff0c\u53ef\u4ee5\u5b9e\u73b0\u5206\u6b21\u63d0\u4ea4\n$ git add -p\n\n# \u5220\u9664\u5de5\u4f5c\u533a\u6587\u4ef6\uff0c\u5e76\u4e14\u5c06\u8fd9\u6b21\u5220\u9664\u653e\u5165\u6682\u5b58\u533a\n$ git rm &#091;file1] &#091;file2] ...\n\n# \u505c\u6b62\u8ffd\u8e2a\u6307\u5b9a\u6587\u4ef6\uff0c\u4f46\u8be5\u6587\u4ef6\u4f1a\u4fdd\u7559\u5728\u5de5\u4f5c\u533a\n$ git rm --cached &#091;file]\n\n# \u6539\u540d\u6587\u4ef6\uff0c\u5e76\u4e14\u5c06\u8fd9\u4e2a\u6539\u540d\u653e\u5165\u6682\u5b58\u533a\n$ git mv &#091;file-original] &#091;file-renamed]\n<\/code><\/pre>\n\n\n\n<h2>\u56db\u3001\u4ee3\u7801\u63d0\u4ea4<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>\n# \u63d0\u4ea4\u6682\u5b58\u533a\u5230\u4ed3\u5e93\u533a\n$ git commit -m &#091;message]\n\n# \u63d0\u4ea4\u6682\u5b58\u533a\u7684\u6307\u5b9a\u6587\u4ef6\u5230\u4ed3\u5e93\u533a\n$ git commit &#091;file1] &#091;file2] ... -m &#091;message]\n\n# \u63d0\u4ea4\u5de5\u4f5c\u533a\u81ea\u4e0a\u6b21commit\u4e4b\u540e\u7684\u53d8\u5316\uff0c\u76f4\u63a5\u5230\u4ed3\u5e93\u533a\n$ git commit -a\n\n# \u63d0\u4ea4\u65f6\u663e\u793a\u6240\u6709diff\u4fe1\u606f\n$ git commit -v\n\n# \u4f7f\u7528\u4e00\u6b21\u65b0\u7684commit\uff0c\u66ff\u4ee3\u4e0a\u4e00\u6b21\u63d0\u4ea4\n# \u5982\u679c\u4ee3\u7801\u6ca1\u6709\u4efb\u4f55\u65b0\u53d8\u5316\uff0c\u5219\u7528\u6765\u6539\u5199\u4e0a\u4e00\u6b21commit\u7684\u63d0\u4ea4\u4fe1\u606f\n$ git commit --amend -m &#091;message]\n\n# \u91cd\u505a\u4e0a\u4e00\u6b21commit\uff0c\u5e76\u5305\u62ec\u6307\u5b9a\u6587\u4ef6\u7684\u65b0\u53d8\u5316\n$ git commit --amend &#091;file1] &#091;file2] ...\n<\/code><\/pre>\n\n\n\n<h2>\u4e94\u3001\u5206\u652f<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>\n# \u5217\u51fa\u6240\u6709\u672c\u5730\u5206\u652f\n$ git branch\n\n# \u5217\u51fa\u6240\u6709\u8fdc\u7a0b\u5206\u652f\n$ git branch -r\n\n# \u5217\u51fa\u6240\u6709\u672c\u5730\u5206\u652f\u548c\u8fdc\u7a0b\u5206\u652f\n$ git branch -a\n\n# \u65b0\u5efa\u4e00\u4e2a\u5206\u652f\uff0c\u4f46\u4f9d\u7136\u505c\u7559\u5728\u5f53\u524d\u5206\u652f\n$ git branch &#091;branch-name]\n\n# \u65b0\u5efa\u4e00\u4e2a\u5206\u652f\uff0c\u5e76\u5207\u6362\u5230\u8be5\u5206\u652f\n$ git checkout -b &#091;branch]\n\n# \u65b0\u5efa\u4e00\u4e2a\u5206\u652f\uff0c\u6307\u5411\u6307\u5b9acommit\n$ git branch &#091;branch] &#091;commit]\n\n# \u65b0\u5efa\u4e00\u4e2a\u5206\u652f\uff0c\u4e0e\u6307\u5b9a\u7684\u8fdc\u7a0b\u5206\u652f\u5efa\u7acb\u8ffd\u8e2a\u5173\u7cfb\n$ git branch --track &#091;branch] &#091;remote-branch]\n\n# \u5207\u6362\u5230\u6307\u5b9a\u5206\u652f\uff0c\u5e76\u66f4\u65b0\u5de5\u4f5c\u533a\n$ git checkout &#091;branch-name]\n\n# \u5207\u6362\u5230\u4e0a\u4e00\u4e2a\u5206\u652f\n$ git checkout -\n\n# \u5efa\u7acb\u8ffd\u8e2a\u5173\u7cfb\uff0c\u5728\u73b0\u6709\u5206\u652f\u4e0e\u6307\u5b9a\u7684\u8fdc\u7a0b\u5206\u652f\u4e4b\u95f4\n$ git branch --set-upstream &#091;branch] &#091;remote-branch]\n\n# \u5408\u5e76\u6307\u5b9a\u5206\u652f\u5230\u5f53\u524d\u5206\u652f\n$ git merge &#091;branch]\n\n# \u9009\u62e9\u4e00\u4e2acommit\uff0c\u5408\u5e76\u8fdb\u5f53\u524d\u5206\u652f\n$ git cherry-pick &#091;commit]\n\n# \u5220\u9664\u5206\u652f\n$ git branch -d &#091;branch-name]\n\n# \u5220\u9664\u8fdc\u7a0b\u5206\u652f\n$ git push origin --delete &#091;branch-name]\n$ git branch -dr &#091;remote\/branch]\n<\/code><\/pre>\n\n\n\n<h2>\u516d\u3001\u6807\u7b7e<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>\n# \u5217\u51fa\u6240\u6709tag\n$ git tag\n\n# \u65b0\u5efa\u4e00\u4e2atag\u5728\u5f53\u524dcommit\n$ git tag &#091;tag]\n\n# \u65b0\u5efa\u4e00\u4e2atag\u5728\u6307\u5b9acommit\n$ git tag &#091;tag] &#091;commit]\n\n# \u5220\u9664\u672c\u5730tag\n$ git tag -d &#091;tag]\n\n# \u5220\u9664\u8fdc\u7a0btag\n$ git push origin :refs\/tags\/&#091;tagName]\n\n# \u67e5\u770btag\u4fe1\u606f\n$ git show &#091;tag]\n\n# \u63d0\u4ea4\u6307\u5b9atag\n$ git push &#091;remote] &#091;tag]\n\n# \u63d0\u4ea4\u6240\u6709tag\n$ git push &#091;remote] --tags\n\n# \u65b0\u5efa\u4e00\u4e2a\u5206\u652f\uff0c\u6307\u5411\u67d0\u4e2atag\n$ git checkout -b &#091;branch] &#091;tag]\n<\/code><\/pre>\n\n\n\n<h2>\u4e03\u3001\u67e5\u770b\u4fe1\u606f<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>\n# \u663e\u793a\u6709\u53d8\u66f4\u7684\u6587\u4ef6\n$ git status\n\n# \u663e\u793a\u5f53\u524d\u5206\u652f\u7684\u7248\u672c\u5386\u53f2\n$ git log\n\n# \u663e\u793acommit\u5386\u53f2\uff0c\u4ee5\u53ca\u6bcf\u6b21commit\u53d1\u751f\u53d8\u66f4\u7684\u6587\u4ef6\n$ git log --stat\n\n# \u641c\u7d22\u63d0\u4ea4\u5386\u53f2\uff0c\u6839\u636e\u5173\u952e\u8bcd\n$ git log -S &#091;keyword]\n\n# \u663e\u793a\u67d0\u4e2acommit\u4e4b\u540e\u7684\u6240\u6709\u53d8\u52a8\uff0c\u6bcf\u4e2acommit\u5360\u636e\u4e00\u884c\n$ git log &#091;tag] HEAD --pretty=format:%s\n\n# \u663e\u793a\u67d0\u4e2acommit\u4e4b\u540e\u7684\u6240\u6709\u53d8\u52a8\uff0c\u5176\"\u63d0\u4ea4\u8bf4\u660e\"\u5fc5\u987b\u7b26\u5408\u641c\u7d22\u6761\u4ef6\n$ git log &#091;tag] HEAD --grep feature\n\n# \u663e\u793a\u67d0\u4e2a\u6587\u4ef6\u7684\u7248\u672c\u5386\u53f2\uff0c\u5305\u62ec\u6587\u4ef6\u6539\u540d\n$ git log --follow &#091;file]\n$ git whatchanged &#091;file]\n\n# \u663e\u793a\u6307\u5b9a\u6587\u4ef6\u76f8\u5173\u7684\u6bcf\u4e00\u6b21diff\n$ git log -p &#091;file]\n\n# \u663e\u793a\u8fc7\u53bb5\u6b21\u63d0\u4ea4\n$ git log -5 --pretty --oneline\n\n# \u663e\u793a\u6240\u6709\u63d0\u4ea4\u8fc7\u7684\u7528\u6237\uff0c\u6309\u63d0\u4ea4\u6b21\u6570\u6392\u5e8f\n$ git shortlog -sn\n\n# \u663e\u793a\u6307\u5b9a\u6587\u4ef6\u662f\u4ec0\u4e48\u4eba\u5728\u4ec0\u4e48\u65f6\u95f4\u4fee\u6539\u8fc7\n$ git blame &#091;file]\n\n# \u663e\u793a\u6682\u5b58\u533a\u548c\u5de5\u4f5c\u533a\u7684\u5dee\u5f02\n$ git diff\n\n# \u663e\u793a\u6682\u5b58\u533a\u548c\u4e0a\u4e00\u4e2acommit\u7684\u5dee\u5f02\n$ git diff --cached &#091;file]\n\n# \u663e\u793a\u5de5\u4f5c\u533a\u4e0e\u5f53\u524d\u5206\u652f\u6700\u65b0commit\u4e4b\u95f4\u7684\u5dee\u5f02\n$ git diff HEAD\n\n# \u663e\u793a\u4e24\u6b21\u63d0\u4ea4\u4e4b\u95f4\u7684\u5dee\u5f02\n$ git diff &#091;first-branch]...&#091;second-branch]\n\n# \u663e\u793a\u4eca\u5929\u4f60\u5199\u4e86\u591a\u5c11\u884c\u4ee3\u7801\n$ git diff --shortstat \"@{0 day ago}\"\n\n# \u663e\u793a\u67d0\u6b21\u63d0\u4ea4\u7684\u5143\u6570\u636e\u548c\u5185\u5bb9\u53d8\u5316\n$ git show &#091;commit]\n\n# \u663e\u793a\u67d0\u6b21\u63d0\u4ea4\u53d1\u751f\u53d8\u5316\u7684\u6587\u4ef6\n$ git show --name-only &#091;commit]\n\n# \u663e\u793a\u67d0\u6b21\u63d0\u4ea4\u65f6\uff0c\u67d0\u4e2a\u6587\u4ef6\u7684\u5185\u5bb9\n$ git show &#091;commit]:&#091;filename]\n\n# \u663e\u793a\u5f53\u524d\u5206\u652f\u7684\u6700\u8fd1\u51e0\u6b21\u63d0\u4ea4\n$ git reflog\n<\/code><\/pre>\n\n\n\n<h2>\u516b\u3001\u8fdc\u7a0b\u540c\u6b65<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>\n# \u4e0b\u8f7d\u8fdc\u7a0b\u4ed3\u5e93\u7684\u6240\u6709\u53d8\u52a8\n$ git fetch &#091;remote]\n\n# \u663e\u793a\u6240\u6709\u8fdc\u7a0b\u4ed3\u5e93\n$ git remote -v\n\n# \u663e\u793a\u67d0\u4e2a\u8fdc\u7a0b\u4ed3\u5e93\u7684\u4fe1\u606f\n$ git remote show &#091;remote]\n\n# \u589e\u52a0\u4e00\u4e2a\u65b0\u7684\u8fdc\u7a0b\u4ed3\u5e93\uff0c\u5e76\u547d\u540d\n$ git remote add &#091;shortname] &#091;url]\n\n# \u53d6\u56de\u8fdc\u7a0b\u4ed3\u5e93\u7684\u53d8\u5316\uff0c\u5e76\u4e0e\u672c\u5730\u5206\u652f\u5408\u5e76\n$ git pull &#091;remote] &#091;branch]\n\n# \u4e0a\u4f20\u672c\u5730\u6307\u5b9a\u5206\u652f\u5230\u8fdc\u7a0b\u4ed3\u5e93\n$ git push &#091;remote] &#091;branch]\n\n# \u5f3a\u884c\u63a8\u9001\u5f53\u524d\u5206\u652f\u5230\u8fdc\u7a0b\u4ed3\u5e93\uff0c\u5373\u4f7f\u6709\u51b2\u7a81\n$ git push &#091;remote] --force\n\n# \u63a8\u9001\u6240\u6709\u5206\u652f\u5230\u8fdc\u7a0b\u4ed3\u5e93\n$ git push &#091;remote] --all\n<\/code><\/pre>\n\n\n\n<h2>\u4e5d\u3001\u64a4\u9500<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>\n# \u6062\u590d\u6682\u5b58\u533a\u7684\u6307\u5b9a\u6587\u4ef6\u5230\u5de5\u4f5c\u533a\n$ git checkout &#091;file]\n\n# \u6062\u590d\u67d0\u4e2acommit\u7684\u6307\u5b9a\u6587\u4ef6\u5230\u6682\u5b58\u533a\u548c\u5de5\u4f5c\u533a\n$ git checkout &#091;commit] &#091;file]\n\n# \u6062\u590d\u6682\u5b58\u533a\u7684\u6240\u6709\u6587\u4ef6\u5230\u5de5\u4f5c\u533a\n$ git checkout .\n\n# \u91cd\u7f6e\u6682\u5b58\u533a\u7684\u6307\u5b9a\u6587\u4ef6\uff0c\u4e0e\u4e0a\u4e00\u6b21commit\u4fdd\u6301\u4e00\u81f4\uff0c\u4f46\u5de5\u4f5c\u533a\u4e0d\u53d8\n$ git reset &#091;file]\n\n# \u91cd\u7f6e\u6682\u5b58\u533a\u4e0e\u5de5\u4f5c\u533a\uff0c\u4e0e\u4e0a\u4e00\u6b21commit\u4fdd\u6301\u4e00\u81f4\n$ git reset --hard\n\n# \u91cd\u7f6e\u5f53\u524d\u5206\u652f\u7684\u6307\u9488\u4e3a\u6307\u5b9acommit\uff0c\u540c\u65f6\u91cd\u7f6e\u6682\u5b58\u533a\uff0c\u4f46\u5de5\u4f5c\u533a\u4e0d\u53d8\n$ git reset &#091;commit]\n\n# \u91cd\u7f6e\u5f53\u524d\u5206\u652f\u7684HEAD\u4e3a\u6307\u5b9acommit\uff0c\u540c\u65f6\u91cd\u7f6e\u6682\u5b58\u533a\u548c\u5de5\u4f5c\u533a\uff0c\u4e0e\u6307\u5b9acommit\u4e00\u81f4\n$ git reset --hard &#091;commit]\n\n# \u91cd\u7f6e\u5f53\u524dHEAD\u4e3a\u6307\u5b9acommit\uff0c\u4f46\u4fdd\u6301\u6682\u5b58\u533a\u548c\u5de5\u4f5c\u533a\u4e0d\u53d8\n$ git reset --keep &#091;commit]\n\n# \u65b0\u5efa\u4e00\u4e2acommit\uff0c\u7528\u6765\u64a4\u9500\u6307\u5b9acommit\n# \u540e\u8005\u7684\u6240\u6709\u53d8\u5316\u90fd\u5c06\u88ab\u524d\u8005\u62b5\u6d88\uff0c\u5e76\u4e14\u5e94\u7528\u5230\u5f53\u524d\u5206\u652f\n$ git revert &#091;commit]\n\n# \u6682\u65f6\u5c06\u672a\u63d0\u4ea4\u7684\u53d8\u5316\u79fb\u9664\uff0c\u7a0d\u540e\u518d\u79fb\u5165\n$ git stash\n$ git stash pop\n<\/code><\/pre>\n\n\n\n<h2>\u5341\u3001\u5176\u4ed6<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>\n# \u751f\u6210\u4e00\u4e2a\u53ef\u4f9b\u53d1\u5e03\u7684\u538b\u7f29\u5305\n$ git archive<\/code><\/pre>\n\n\n\n<h2>\u6c47\u603b\u8868\uff1a<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>git init # \u521d\u59cb\u5316\u672c\u5730git\u4ed3\u5e93\uff08\u521b\u5efa\u65b0\u4ed3\u5e93\uff09<br>git config &#8211;global user.name &#8220;xxx&#8221; # \u914d\u7f6e\u7528\u6237\u540d<\/td><\/tr><tr><td>git config &#8211;global user.email &#8220;xxx@xxx.com&#8221; # \u914d\u7f6e\u90ae\u4ef6<\/td><\/tr><tr><td>git config &#8211;global color.ui true # git status\u7b49\u547d\u4ee4\u81ea\u52a8\u7740\u8272<\/td><\/tr><tr><td>git config &#8211;global color.status auto<\/td><\/tr><tr><td>git config &#8211;global color.diff auto<\/td><\/tr><tr><td>git config &#8211;global color.branch auto<\/td><\/tr><tr><td>git config &#8211;global color.interactive auto<\/td><\/tr><tr><td>git config &#8211;global &#8211;unset http.proxy # remove proxy configuration on git<\/td><\/tr><tr><td>git clone git+ssh:\/\/git@192.168.53.168\/VT.git # clone\u8fdc\u7a0b\u4ed3\u5e93<\/td><\/tr><tr><td>git status # \u67e5\u770b\u5f53\u524d\u7248\u672c\u72b6\u6001\uff08\u662f\u5426\u4fee\u6539\uff09<\/td><\/tr><tr><td>git add xyz # \u6dfb\u52a0xyz\u6587\u4ef6\u81f3index<\/td><\/tr><tr><td>git add . # \u589e\u52a0\u5f53\u524d\u5b50\u76ee\u5f55\u4e0b\u6240\u6709\u66f4\u6539\u8fc7\u7684\u6587\u4ef6\u81f3index<\/td><\/tr><tr><td>git commit -m &#8216;xxx&#8217; # \u63d0\u4ea4<\/td><\/tr><tr><td>git commit &#8211;amend -m &#8216;xxx&#8217; # \u5408\u5e76\u4e0a\u4e00\u6b21\u63d0\u4ea4\uff08\u7528\u4e8e\u53cd\u590d\u4fee\u6539\uff09<\/td><\/tr><tr><td>git commit -am &#8216;xxx&#8217; # \u5c06add\u548ccommit\u5408\u4e3a\u4e00\u6b65<\/td><\/tr><tr><td>git rm xxx # \u5220\u9664index\u4e2d\u7684\u6587\u4ef6<\/td><\/tr><tr><td>git rm -r * # \u9012\u5f52\u5220\u9664<\/td><\/tr><tr><td>git log # \u663e\u793a\u63d0\u4ea4\u65e5\u5fd7<\/td><\/tr><tr><td>git log -1 # \u663e\u793a1\u884c\u65e5\u5fd7 -n\u4e3an\u884c<\/td><\/tr><tr><td>git log -5<\/td><\/tr><tr><td>git log &#8211;stat # \u663e\u793a\u63d0\u4ea4\u65e5\u5fd7\u53ca\u76f8\u5173\u53d8\u52a8\u6587\u4ef6<\/td><\/tr><tr><td>git log -p -m<\/td><\/tr><tr><td>git show dfb02e6e4f2f7b573337763e5c0013802e392818 # \u663e\u793a\u67d0\u4e2a\u63d0\u4ea4\u7684\u8be6\u7ec6\u5185\u5bb9<\/td><\/tr><tr><td>git show dfb02 # \u53ef\u53ea\u7528commitid\u7684\u524d\u51e0\u4f4d<\/td><\/tr><tr><td>git show HEAD # \u663e\u793aHEAD\u63d0\u4ea4\u65e5\u5fd7<\/td><\/tr><tr><td>git 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<\/td><\/tr><tr><td>git tag # \u663e\u793a\u5df2\u5b58\u5728\u7684tag<\/td><\/tr><tr><td>git tag -a v2.0 -m &#8216;xxx&#8217; # \u589e\u52a0v2.0\u7684tag<\/td><\/tr><tr><td>git show v2.0 # \u663e\u793av2.0\u7684\u65e5\u5fd7\u53ca\u8be6\u7ec6\u5185\u5bb9<\/td><\/tr><tr><td>git log v2.0 # \u663e\u793av2.0\u7684\u65e5\u5fd7<\/td><\/tr><tr><td>git diff # \u663e\u793a\u6240\u6709\u672a\u6dfb\u52a0\u81f3index\u7684\u53d8\u66f4<\/td><\/tr><tr><td>git diff &#8211;cached # \u663e\u793a\u6240\u6709\u5df2\u6dfb\u52a0index\u4f46\u8fd8\u672acommit\u7684\u53d8\u66f4<\/td><\/tr><tr><td>git diff HEAD^ # \u6bd4\u8f83\u4e0e\u4e0a\u4e00\u4e2a\u7248\u672c\u7684\u5dee\u5f02<\/td><\/tr><tr><td>git diff HEAD &#8212; .\/lib # \u6bd4\u8f83\u4e0eHEAD\u7248\u672clib\u76ee\u5f55\u7684\u5dee\u5f02<\/td><\/tr><tr><td>git diff origin\/master..master # \u6bd4\u8f83\u8fdc\u7a0b\u5206\u652fmaster\u4e0a\u6709\u672c\u5730\u5206\u652fmaster\u4e0a\u6ca1\u6709\u7684<\/td><\/tr><tr><td>git diff origin\/master..master &#8211;stat # \u53ea\u663e\u793a\u5dee\u5f02\u7684\u6587\u4ef6\uff0c\u4e0d\u663e\u793a\u5177\u4f53\u5185\u5bb9<\/td><\/tr><tr><td>git remote add origin git+ssh:\/\/git@192.168.53.168\/VT.git # \u589e\u52a0\u8fdc\u7a0b\u5b9a\u4e49\uff08\u7528\u4e8epush\/pull\/fetch\uff09<\/td><\/tr><tr><td>git branch # \u663e\u793a\u672c\u5730\u5206\u652f<\/td><\/tr><tr><td>git branch &#8211;contains 50089 # \u663e\u793a\u5305\u542b\u63d0\u4ea450089\u7684\u5206\u652f<\/td><\/tr><tr><td>git branch -a # \u663e\u793a\u6240\u6709\u5206\u652f<\/td><\/tr><tr><td>git branch -r # \u663e\u793a\u6240\u6709\u539f\u521b\u5206\u652f<\/td><\/tr><tr><td>git branch &#8211;merged # \u663e\u793a\u6240\u6709\u5df2\u5408\u5e76\u5230\u5f53\u524d\u5206\u652f\u7684\u5206\u652f<\/td><\/tr><tr><td>git branch &#8211;no-merged # \u663e\u793a\u6240\u6709\u672a\u5408\u5e76\u5230\u5f53\u524d\u5206\u652f\u7684\u5206\u652f<\/td><\/tr><tr><td>git branch -m master master_copy # \u672c\u5730\u5206\u652f\u6539\u540d<\/td><\/tr><tr><td>git checkout -b master_copy # \u4ece\u5f53\u524d\u5206\u652f\u521b\u5efa\u65b0\u5206\u652fmaster_copy\u5e76\u68c0\u51fa<\/td><\/tr><tr><td>git checkout -b master master_copy # \u4e0a\u9762\u7684\u5b8c\u6574\u7248<\/td><\/tr><tr><td>git checkout features\/performance # \u68c0\u51fa\u5df2\u5b58\u5728\u7684features\/performance\u5206\u652f<\/td><\/tr><tr><td>git checkout &#8211;track hotfixes\/BJVEP933 # \u68c0\u51fa\u8fdc\u7a0b\u5206\u652fhotfixes\/BJVEP933\u5e76\u521b\u5efa\u672c\u5730\u8ddf\u8e2a\u5206\u652f<\/td><\/tr><tr><td>git checkout v2.0 # \u68c0\u51fa\u7248\u672cv2.0<\/td><\/tr><tr><td>git checkout -b devel origin\/develop # \u4ece\u8fdc\u7a0b\u5206\u652fdevelop\u521b\u5efa\u65b0\u672c\u5730\u5206\u652fdevel\u5e76\u68c0\u51fa<\/td><\/tr><tr><td>git checkout &#8212; README # \u68c0\u51fahead\u7248\u672c\u7684README\u6587\u4ef6\uff08\u53ef\u7528\u4e8e\u4fee\u6539\u9519\u8bef\u56de\u9000\uff09<\/td><\/tr><tr><td>git merge origin\/master # \u5408\u5e76\u8fdc\u7a0bmaster\u5206\u652f\u81f3\u5f53\u524d\u5206\u652f<\/td><\/tr><tr><td>git cherry-pick ff44785404a8e # \u5408\u5e76\u63d0\u4ea4ff44785404a8e\u7684\u4fee\u6539<\/td><\/tr><tr><td>git push origin master # \u5c06\u5f53\u524d\u5206\u652fpush\u5230\u8fdc\u7a0bmaster\u5206\u652f<\/td><\/tr><tr><td>git push origin :hotfixes\/BJVEP933 # \u5220\u9664\u8fdc\u7a0b\u4ed3\u5e93\u7684hotfixes\/BJVEP933\u5206\u652f<\/td><\/tr><tr><td>git push &#8211;tags # \u628a\u6240\u6709tag\u63a8\u9001\u5230\u8fdc\u7a0b\u4ed3\u5e93<\/td><\/tr><tr><td>git fetch # \u83b7\u53d6\u6240\u6709\u8fdc\u7a0b\u5206\u652f\uff08\u4e0d\u66f4\u65b0\u672c\u5730\u5206\u652f\uff0c\u53e6\u9700merge\uff09<\/td><\/tr><tr><td>git fetch &#8211;prune # \u83b7\u53d6\u6240\u6709\u539f\u521b\u5206\u652f\u5e76\u6e05\u9664\u670d\u52a1\u5668\u4e0a\u5df2\u5220\u6389\u7684\u5206\u652f<\/td><\/tr><tr><td>git pull origin master # \u83b7\u53d6\u8fdc\u7a0b\u5206\u652fmaster\u5e76merge\u5230\u5f53\u524d\u5206\u652f<\/td><\/tr><tr><td>git mv README README2 # \u91cd\u547d\u540d\u6587\u4ef6README\u4e3aREADME2<\/td><\/tr><tr><td>git reset &#8211;hard HEAD # \u5c06\u5f53\u524d\u7248\u672c\u91cd\u7f6e\u4e3aHEAD\uff08\u901a\u5e38\u7528\u4e8emerge\u5931\u8d25\u56de\u9000\uff09<\/td><\/tr><tr><td>git rebase<\/td><\/tr><tr><td>git branch -d hotfixes\/BJVEP933 # \u5220\u9664\u5206\u652fhotfixes\/BJVEP933\uff08\u672c\u5206\u652f\u4fee\u6539\u5df2\u5408\u5e76\u5230\u5176\u4ed6\u5206\u652f\uff09<\/td><\/tr><tr><td>git branch -D hotfixes\/BJVEP933 # \u5f3a\u5236\u5220\u9664\u5206\u652fhotfixes\/BJVEP933<\/td><\/tr><tr><td>git ls-files # \u5217\u51fagit index\u5305\u542b\u7684\u6587\u4ef6<\/td><\/tr><tr><td>git show-branch # \u56fe\u793a\u5f53\u524d\u5206\u652f\u5386\u53f2<\/td><\/tr><tr><td>git show-branch &#8211;all # \u56fe\u793a\u6240\u6709\u5206\u652f\u5386\u53f2<\/td><\/tr><tr><td>git whatchanged # \u663e\u793a\u63d0\u4ea4\u5386\u53f2\u5bf9\u5e94\u7684\u6587\u4ef6\u4fee\u6539<\/td><\/tr><tr><td>git revert dfb02e6e4f2f7b573337763e5c0013802e392818 # \u64a4\u9500\u63d0\u4ea4dfb02e6e4f2f7b573337763e5c0013802e392818<\/td><\/tr><tr><td>git ls-tree HEAD # \u5185\u90e8\u547d\u4ee4\uff1a\u663e\u793a\u67d0\u4e2agit\u5bf9\u8c61<\/td><\/tr><tr><td>git rev-parse v2.0 # \u5185\u90e8\u547d\u4ee4\uff1a\u663e\u793a\u67d0\u4e2aref\u5bf9\u4e8e\u7684SHA1 HASH<\/td><\/tr><tr><td>git reflog # \u663e\u793a\u6240\u6709\u63d0\u4ea4\uff0c\u5305\u62ec\u5b64\u7acb\u8282\u70b9<\/td><\/tr><tr><td>git show HEAD@{5}<\/td><\/tr><tr><td>git show master@{yesterday} # \u663e\u793amaster\u5206\u652f\u6628\u5929\u7684\u72b6\u6001<\/td><\/tr><tr><td>git log &#8211;pretty=format:&#8217;%h %s&#8217; &#8211;graph # \u56fe\u793a\u63d0\u4ea4\u65e5\u5fd7<\/td><\/tr><tr><td>git show HEAD~3<\/td><\/tr><tr><td>git show -s &#8211;pretty=raw 2be7fcb476<\/td><\/tr><tr><td>git stash # \u6682\u5b58\u5f53\u524d\u4fee\u6539\uff0c\u5c06\u6240\u6709\u81f3\u4e3aHEAD\u72b6\u6001<\/td><\/tr><tr><td>git stash list # \u67e5\u770b\u6240\u6709\u6682\u5b58<\/td><\/tr><tr><td>git stash show -p stash@{0} # \u53c2\u8003\u7b2c\u4e00\u6b21\u6682\u5b58<\/td><\/tr><tr><td>git stash apply stash@{0} # \u5e94\u7528\u7b2c\u4e00\u6b21\u6682\u5b58<\/td><\/tr><tr><td>git grep &#8220;delete from&#8221; # \u6587\u4ef6\u4e2d\u641c\u7d22\u6587\u672c\u201cdelete from\u201d<\/td><\/tr><tr><td>git grep -e &#8216;#define&#8217; &#8211;and -e SORT_DIRENT<\/td><\/tr><tr><td>git gc<\/td><\/tr><tr><td>git fsck<\/td><\/tr><\/tbody><\/table><figcaption>\u53c2\u8003\uff1a<br>https:\/\/git-scm.com\/docs\/git-add<br><a href=\"https:\/\/www.ruanyifeng.com\/blog\/2015\/12\/git-cheat-sheet.html\">https:\/\/www.ruanyifeng.com\/blog\/2015\/12\/git-cheat-sheet.html<\/a><br><a href=\"https:\/\/gist.github.com\/guweigang\/9848271#file-git_toturial\">https:\/\/gist.github.com\/guweigang\/9848271#file-git_toturial<\/a><\/figcaption><\/figure>\n\n\n\n<h2>\u81ea\u5df1\u7406\u89e3\uff1a<\/h2>\n\n\n\n<h3>\u7f16\u5199\u524d<\/h3>\n\n\n\n<p>Git checkout&nbsp; liangchen<\/p>\n\n\n\n<p>#\u5148\u62c9\u53bb\u8fdc\u7a0b\u5206\u652f\u4ee3\u7801<\/p>\n\n\n\n<p>Git pull origin liangxianchen:liangxianchen<\/p>\n\n\n\n<p>Git add \u6211\u6539\u8fc7\u7684\u4ee3\u7801\u6587\u4ef6 &nbsp;#\u53ea\u63d0\u4ea4\u81ea\u5df1\u8be5\u8fc7\u7684\u4ee3\u7801<\/p>\n\n\n\n<p>Git commit -m<\/p>\n\n\n\n<p>Git push origin liangchen:liangxianchen(\u4eceliangchen\u672c\u5730\u5206\u652f\u63a8\u9001\u5230liangxianchen\u8fdc\u7a0b\u5206\u652f)<\/p>\n\n\n\n<p>\u7f16\u5199\u4ee3\u7801<\/p>\n\n\n\n<p>\u5982\u679c\u60f3\u56de\u63a8\u4ee3\u7801\u5728\u6ca1\u6709\u63d0\u4ea4\u524d<\/p>\n\n\n\n<p>Git status<\/p>\n\n\n\n<p>git diff \u88ab\u4fee\u6539\u7684\u6587\u4ef6\u540d<\/p>\n\n\n\n<p>\u5c31\u53ef\u4ee5\u770b\u5230\u88ab\u4fee\u6539\u8fc7\u7684\u539f\u59cb\u5185\u5bb9<\/p>\n\n\n\n<h3>Git \u51fa\u73b0\uff01reject\u7684\u60c5\u51b5<\/h3>\n\n\n\n<p>\u89e3\u51b3\u529e\u6cd5\uff1a\u9996\u5148\u5c06\u672c\u5730\u4fee\u6539\u7684\u6587\u4ef6\u5907\u4efd\uff0c\u7136\u540e\u5f3a\u5236\u8ba9\u8fdc\u7a0b\u6587\u4ef6\u8986\u76d6\u672c\u5730\u4ed3\u5e93\u6587\u4ef6<\/p>\n\n\n\n<p>Git fetch \u2013all<\/p>\n\n\n\n<p>Git reset \u2013hard origin\/liangxianchen<\/p>\n\n\n\n<p>\u5f53\u5220\u9664\u672c\u5730\u6587\u4ef6\u540e\uff0c\u5982\u4f55\u4e0e\u8fdc\u7aef\u540c\u6b65\uff1f<\/p>\n\n\n\n<p>\u9996\u5148\u4e0d\u80fd\u76f4\u63a5\u5728\u672c\u5730\u6309del\u952e\u5220\u9664\uff0c\u8fd9\u6837\u5bf9\u8fdc\u7aef\u6ca1\u6709\u4efb\u4f55\u5f71\u54cd\uff0c\u5fc5\u987b\u4f7f\u7528git rm filename \u547d\u4ee4\u5220\u9664\uff0c\u5176\u6b21\uff0c\u5220\u9664\u5b8c\u4e4b\u540e\uff0cgit commit -m \u201cdelete filename\u201d \u4e00\u4e0b\uff0c\u6700\u540e git push\u5c31OK\u4e86<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Workspace\uff1a\u5de5\u4f5c\u533a Index \/ Stage\uff1a\u6682\u5b58\u533a Repository\uff1a\u4ed3\u5e93\u533a\uff08\u6216\u672c\u5730\u4ed3\u5e93\uff09 R &hellip; <a href=\"http:\/\/139.9.1.231\/index.php\/2021\/12\/28\/git\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u5e38\u7528git\u547d\u4ee4\u6c47\u603b<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[],"_links":{"self":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/856"}],"collection":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/comments?post=856"}],"version-history":[{"count":83,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/856\/revisions"}],"predecessor-version":[{"id":4665,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/856\/revisions\/4665"}],"wp:attachment":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/media?parent=856"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/categories?post=856"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/tags?post=856"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}