{"id":710,"date":"2016-07-01T17:31:21","date_gmt":"2016-07-01T09:31:21","guid":{"rendered":"http:\/\/www.shuran.cn\/?p=710"},"modified":"2016-07-01T17:31:21","modified_gmt":"2016-07-01T09:31:21","slug":"30%e5%88%86%e9%92%9fgit%e5%91%bd%e4%bb%a4%e5%85%a5%e9%97%a8","status":"publish","type":"post","link":"https:\/\/www.shuran.cn\/?p=710","title":{"rendered":"30\u5206\u949fgit\u547d\u4ee4\u5165\u95e8"},"content":{"rendered":"<h2 id=\"\u57fa\u672c\u4e86\u89e3\" style=\"color:#50585D;font-weight:500;font-size:1.6em;font-family:&quot;background-color:#FFFFFF;\">\n\t\u57fa\u672c\u4e86\u89e3<br \/>\n<\/h2>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\tgit\u547d\u4ee4\u662f\u4e00\u4e9b\u547d\u4ee4\u884c\u5de5\u5177\u7684\u96c6\u5408\uff0c\u5b83\u53ef\u4ee5\u7528\u6765\u8ddf\u8e2a\uff0c\u8bb0\u5f55\u6587\u4ef6\u7684\u53d8\u52a8\u3002\u6bd4\u5982\u4f60\u53ef\u4ee5\u8fdb\u884c\u4fdd\u5b58\uff0c\u6bd4\u5bf9\uff0c\u5206\u6790\uff0c\u5408\u5e76\u7b49\u7b49\u3002\u8fd9\u4e2a\u8fc7\u7a0b\u88ab\u79f0\u4e4b\u4e3a\u7248\u672c\u63a7\u5236\u3002\u5df2\u7ecf\u6709\u4e00\u7cfb\u5217\u7684\u7248\u672c\u63a7\u5236\u7cfb\u7edf\uff0c\u6bd4\u5982SVN, Mercurial, Perforce, CVS, Bitkeepe\u7b49\u7b49\u3002\n<\/p>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\tGit\u662f\u5206\u5e03\u5f0f\u7684\uff0c\u8fd9\u610f\u5473\u7740\u5b83\u5e76\u4e0d\u4f9d\u8d56\u4e8e\u4e2d\u5fc3\u670d\u52a1\u5668\uff0c\u4efb\u4f55\u4e00\u53f0\u673a\u5668\u90fd\u53ef\u4ee5\u6709\u4e00\u4e2a\u672c\u5730\u7248\u672c\u7684\u63a7\u5236\u7cfb\u7edf\uff0c\u6211\u4eec\u79f0\u4e4b\u4e3a\u4ed3\u5e93\u3002\u5982\u679c\u662f\u591a\u4eba\u534f\u4f5c\u7684\u8bdd\uff0c\u4f60\u9700\u8981\u8fd8\u9700\u8981\u4e00\u4e2a\u7ebf\u4e0a\u4ed3\u5e93\uff0c\u7528\u6765\u540c\u6b65\u4fe1\u606f\u3002\u8fd9\u5c31\u662fGitHub, BitBucket\u7684\u5de5\u4f5c\u3002\n<\/p>\n<h3 id=\"1-\u5b89\u88c5Git\" style=\"color:#50585D;font-weight:500;font-size:1.4em;font-family:&quot;background-color:#FFFFFF;\">\n\t1.\u5b89\u88c5Git<br \/>\n<\/h3>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u5b89\u88c5git\u975e\u5e38\u76f4\u63a5\uff1a\n<\/p>\n<ul style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n<li>\n<p>\n\t\t\tLinux - \u6253\u5f00\u63a7\u5236\u53f0\uff0c\u7136\u540e\u901a\u8fc7\u5305\u7ba1\u7406\u5b89\u88c5\uff0c\u5728Ubuntu\u4e0a\u547d\u4ee4\u662f\uff1a\n\t\t<\/p>\n<div class=\"highlight-wrap\" style=\"background:#eeeeee;\">\n<table style=\"margin:0px;border:none;padding:10px;width:auto;\">\n<tbody>\n<tr>\n<td class=\"code\" style=\"border:none;\">\n<pre><span class=\"line\">sudo apt-get install git-all<\/span> <\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/div>\n<\/li>\n<li>\n<p>\n\t\t\tWindows - \u63a8\u8350\u4f7f\u7528<a href=\"https:\/\/git-for-windows.github.io\/\" target=\"_blank\">git for windows<\/a>\uff0c\u5b83\u5305\u62ec\u4e86\u56fe\u5f62\u5de5\u5177\u4ee5\u53ca\u547d\u4ee4\u884c\u6a21\u62df\u5668\u3002\n\t\t<\/p>\n<\/li>\n<li>\n\t\tOS X - \u6700\u7b80\u5355\u7684\u65b9\u5f0f\u662f\u4f7f\u7528homebrew\u5b89\u88c5\uff0c\u547d\u4ee4\u884c\u6267\u884c<\/p>\n<div class=\"highlight-wrap\" style=\"background:#eeeeee;\">\n<table style=\"margin:0px;border:none;padding:10px;width:auto;\">\n<tbody>\n<tr>\n<td class=\"code\" style=\"border:none;\">\n<pre><span class=\"line\">brew install git<\/span> <\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/div>\n<\/li>\n<\/ul>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u5982\u679c\u4f60\u662f\u5728\u662f\u5148\u7528\u56fe\u5f62\u5de5\u5177\u7684\u8bdd\uff0c\u90a3\u4e48\u63a8\u8350\u4f60\u4f7f\u7528<a href=\"https:\/\/desktop.github.com\/\" target=\"_blank\">Github desktop<\/a>,<a href=\"https:\/\/www.atlassian.com\/software\/sourcetree\" target=\"_blank\">Sourcetree<\/a>\u3002\u4f46\u6211\u8fd8\u662f\u63a8\u8350\u4f60\u4f7f\u7528\u547d\u4ee4\u884c\uff0c\u4e0b\u9762\u7684\u5185\u5bb9\u5c31\u90fd\u662f\u547d\u4ee4\u884c\u7684\u3002\n<\/p>\n<h3 id=\"2-\u914d\u7f6eGit\" style=\"color:#50585D;font-weight:500;font-size:1.4em;font-family:&quot;background-color:#FFFFFF;\">\n\t2.\u914d\u7f6eGit<br \/>\n<\/h3>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u5b89\u88c5\u5b8cgit,\u9996\u8981\u4efb\u52a1\u662f\u914d\u7f6e\u6211\u4eec\u7684\u4fe1\u606f\uff0c\u6700\u91cd\u8981\u7684\u662f\u7528\u6237\u540d\u53ca\u90ae\u7bb1\uff0c\u6253\u5f00\u7ec8\u7aef\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u3002\n<\/p>\n<div class=\"highlight-wrap\" style=\"background:#eeeeee;color:#444444;font-family:&quot;font-size:18px;\">\n<table style=\"margin:0px;border:none;padding:10px;width:auto;\">\n<tbody>\n<tr>\n<td class=\"code\" style=\"border:none;\">\n<pre><span class=\"line\">$ git config --global user.name \"My Name\"\r\n$ git config --global user.email myEmail@example.com<\/span> <\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u914d\u7f6e\u597d\u8fd9\u4e24\u9879\uff0c\u7528\u6237\u5c31\u80fd\u77e5\u9053\u8c01\u505a\u4e86\u4ec0\u4e48\uff0c\u5e76\u4e14\u4e00\u5207\u90fd\u66f4\u6709\u7ec4\u7ec7\u6027\u4e86\u4e0d\u662f\u5417\uff1f\n<\/p>\n<h3 id=\"3-\u521b\u5efa\u4e00\u4e2a\u65b0\u4ed3\u5e93_-_git_init\" style=\"color:#50585D;font-weight:500;font-size:1.4em;font-family:&quot;background-color:#FFFFFF;\">\n\t3.\u521b\u5efa\u4e00\u4e2a\u65b0\u4ed3\u5e93 - git init<br \/>\n<\/h3>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\tgit \u4f1a\u628a\u6240\u6709\u6587\u4ef6\u4ee5\u53ca\u5386\u53f2\u8bb0\u5f55\u4fdd\u5b58\u5728\u4f60\u7684\u9879\u76ee\u4e2d\uff0c\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u4ed3\u5e93\uff0c\u9996\u5148\u8981\u53bb\u5230\u9879\u76ee\u8def\u5f84\uff0c\u6267\u884c git init\u3002\u7136\u540egit\u4f1a\u521b\u5efa\u4e00\u4e2a\u9690\u85cf\u7684\u6587\u4ef6\u5939.git\uff0c\u6240\u6709\u7684\u4fe1\u606f\u90fd\u50a8\u5b58\u5728\u5176\u4e2d\u3002\n<\/p>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u5728\u684c\u9762\u521b\u5efa\u4e00\u4e2a\u8054\u7cfb\u6587\u4ef6\u5939 git_exercise, \u6253\u5f00\u7ec8\u7aef\uff1a\n<\/p>\n<div class=\"highlight-wrap\" style=\"background:#eeeeee;color:#444444;font-family:&quot;font-size:18px;\">\n<table style=\"margin:0px;border:none;padding:10px;width:auto;\">\n<tbody>\n<tr>\n<td class=\"code\" style=\"border:none;\">\n<pre><span class=\"line\">$ cd Desktop\/git_exercise\/\r\n$ git init<\/span> <\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\tOK\uff0c\u73b0\u5728\u9879\u76ee\u8fd8\u4ec0\u4e48\u90fd\u6ca1\u6709\uff0c\u65b0\u5efa\u4e00\u4e2a hello.txt \u6587\u4ef6\u8bd5\u8bd5~\n<\/p>\n<h3 id=\"4-\u68c0\u67e5\u72b6\u6001_-_git_status\" style=\"color:#50585D;font-weight:500;font-size:1.4em;font-family:&quot;background-color:#FFFFFF;\">\n\t4.\u68c0\u67e5\u72b6\u6001 - git status<br \/>\n<\/h3>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\tgit status \u662f\u53e6\u4e00\u4e2a\u975e\u5e38\u91cd\u8981\u7684\u547d\u4ee4\uff0c\u5b83\u4f1a\u544a\u8bc9\u6211\u4eec\u521b\u5e93\u7684\u5f53\u524d\u72b6\u6001\uff1a\u662f\u5426\u4e3a\u6700\u65b0\u4ee3\u7801\uff0c\u6709\u4ec0\u4e48\u66f4\u65b0\u7b49\u7b49\u6267\u884cgit status:\n<\/p>\n<div class=\"highlight-wrap\" style=\"background:#eeeeee;color:#444444;font-family:&quot;font-size:18px;\">\n<table style=\"margin:0px;border:none;padding:10px;width:auto;\">\n<tbody>\n<tr>\n<td class=\"code\" style=\"border:none;\">\n<pre><span class=\"line\">$ git status\r\n\r\nOn branch master\r\n\r\nInitial commit\r\n\r\nUntracked files:\r\n  (use \"git add ...\" to include in what will be committed)\r\n\r\n\thello.txt<\/span> <\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\tgit \u544a\u8bc9\u6211\u4eec\uff0chello.txt\u5c1a\u672a\u8ddf\u8e2a\uff0c\u8fd9\u662f\u56e0\u4e3a\u8fd9\u4e2a\u6587\u4ef6\u662f\u65b0\u7684\uff0cgit\u4e0d\u77e5\u9053\u662f\u5e94\u8be5\u8ddf\u8e2a\u5b83\u7684\u53d8\u52a8\u5462\uff0c\u8fd8\u662f\u76f4\u63a5\u5ffd\u7565\u4e0d\u7ba1\u5462\u3002\u4e3a\u4e86\u8ddf\u8e2a\u6211\u4eec\u7684\u65b0\u6587\u4ef6\uff0c\u6211\u4eec\u9700\u8981\u6682\u5b58\u5b83\u3002\n<\/p>\n<h3 id=\"5-\u6682\u5b58_-_git_add\" style=\"color:#50585D;font-weight:500;font-size:1.4em;font-family:&quot;background-color:#FFFFFF;\">\n\t5.\u6682\u5b58 - git add<br \/>\n<\/h3>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\tgit \u6709\u4e2a\u6982\u5ff5\u53eb \u6682\u5b58\u533a\uff0c\u4f60\u53ef\u4ee5\u628a\u5b83\u770b\u6210\u4e00\u5757\u7a7a\u767d\u5e06\u5e03\uff0c\u5305\u88f9\u7740\u6240\u6709\u4f60\u53ef\u80fd\u4f1a\u63d0\u4ea4\u7684\u53d8\u52a8\u3002\u5b83\u4e00\u5f00\u59cb\u4e3a\u7a7a\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7 git add \u547d\u4ee4\u6dfb\u52a0\u5185\u5bb9\uff0c\u5e76\u4f7f\u7528 git commit \u63d0\u4ea4\u3002\n<\/p>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\u53ea\u6709\u4e00\u4e2a\u6587\u4ef6\uff1a\n<\/p>\n<div class=\"highlight-wrap\" style=\"background:#eeeeee;color:#444444;font-family:&quot;font-size:18px;\">\n<table style=\"margin:0px;border:none;padding:10px;width:auto;\">\n<tbody>\n<tr>\n<td class=\"code\" style=\"border:none;\">\n<pre><span class=\"line\">$ git add hello.txt<\/span> <\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u5982\u679c\u9700\u8981\u63d0\u4ea4\u76ee\u5f55\u4e0b\u7684\u6240\u6709\u5185\u5bb9\uff0c\u53ef\u4ee5\u8fd9\u6837\uff1a\n<\/p>\n<div class=\"highlight-wrap\" style=\"background:#eeeeee;color:#444444;font-family:&quot;font-size:18px;\">\n<table style=\"margin:0px;border:none;padding:10px;width:auto;\">\n<tbody>\n<tr>\n<td class=\"code\" style=\"border:none;\">\n<pre><span class=\"line\">$ git add -A<\/span> <\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u518d\u6b21\u4f7f\u7528git status\u67e5\u770b\uff1a\n<\/p>\n<div class=\"highlight-wrap\" style=\"background:#eeeeee;color:#444444;font-family:&quot;font-size:18px;\">\n<table style=\"margin:0px;border:none;padding:10px;width:auto;\">\n<tbody>\n<tr>\n<td class=\"code\" style=\"border:none;\">\n<pre><span class=\"line\">$ git status\r\n\r\nOn branch master\r\n\r\nInitial commit\r\n\r\nChanges to be committed:\r\n  (use \"git rm --cached ...\" to unstage)\r\n\r\n\tnew file:   hello.txt<\/span> <\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u6211\u4eec\u7684\u6587\u4ef6\u5df2\u7ecf\u63d0\u4ea4\u4e86\u3002\u72b6\u6001\u4fe1\u606f\u8fd8\u4f1a\u544a\u8bc9\u6211\u4eec\u6682\u5b58\u533a\u6587\u4ef6\u53d1\u751f\u4e86\u4ec0\u4e48\u53d8\u52a8\uff0c\u4e0d\u8fc7\u8fd9\u91cc\u6211\u4eec\u63d0\u4ea4\u7684\u662f\u4e00\u4e2a\u5168\u65b0\u6587\u4ef6\u3002\n<\/p>\n<h3 id=\"6-\u63d0\u4ea4_-_git_commit\" style=\"color:#50585D;font-weight:500;font-size:1.4em;font-family:&quot;background-color:#FFFFFF;\">\n\t6.\u63d0\u4ea4 - git commit<br \/>\n<\/h3>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u4e00\u6b21\u63d0\u4ea4\u4ee3\u8868\u7740\u6211\u4eec\u7684\u4ed3\u5e93\u5230\u4e86\u4e00\u4e2a\u4ea4\u4ed8\u72b6\u6001\uff0c\u901a\u5e38\u662f\u5b8c\u6210\u4e86\u67d0\u4e00\u5757\u5c0f\u529f\u80fd\u3002\u5b83\u5c31\u50cf\u662f\u4e00\u4e2a\u5feb\u7167\uff0c\u5141\u8bb8\u6211\u4eec\u50cf\u4f7f\u7528\u65f6\u5149\u673a\u4e00\u6837\u56de\u5230\u65e7\u65f6\u5149\u3002\n<\/p>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u521b\u5efa\u63d0\u4ea4\uff0c\u9700\u8981\u6211\u4eec\u63d0\u4ea4\u4e1c\u897f\u5230\u6682\u5b58\u533a\uff08git add\uff09\uff0c\u7136\u540e\uff1a\n<\/p>\n<div class=\"highlight-wrap\" style=\"background:#eeeeee;color:#444444;font-family:&quot;font-size:18px;\">\n<table style=\"margin:0px;border:none;padding:10px;width:auto;\">\n<tbody>\n<tr>\n<td class=\"code\" style=\"border:none;\">\n<pre><span class=\"line\">$ git commit -m \"Initial commit.\"<\/span> <\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u8fd9\u5c31\u521b\u5efa\u4e86\u4e00\u6b21\u63d0\u4ea4\uff0c-m \u201cInitial commit.\u201d\u8868\u793a\u5bf9\u8fd9\u6b21\u63d0\u4ea4\u7684\u63cf\u8ff0\uff0c\u5efa\u8bae\u4f7f\u7528\u6709\u610f\u4e49\u7684\u63cf\u8ff0\u6027\u4fe1\u606f\u3002\n<\/p>\n<h2 id=\"\u8fdc\u7aef\u4ed3\u5e93\" style=\"color:#50585D;font-weight:500;font-size:1.6em;font-family:&quot;background-color:#FFFFFF;\">\n\t\u8fdc\u7aef\u4ed3\u5e93<br \/>\n<\/h2>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u5230\u76ee\u524d\u4e3a\u6b62\uff0c\u6211\u4eec\u7684\u64cd\u4f5c\u90fd\u662f\u5728\u672c\u5730\u7684\uff0c\u5b83\u5b58\u5728\u4e8e.git\u6587\u4ef6\u4e2d\u3002\u4e3a\u4e86\u80fd\u591f\u534f\u540c\u5f00\u53d1\uff0c\u6211\u4eec\u9700\u8981\u628a\u4ee3\u7801\u53d1\u5e03\u5230\u8fdc\u7aef\u4ed3\u5e93\u4e0a\u3002\n<\/p>\n<h3 id=\"1-\u94fe\u63a5\u8fdc\u7aef\u4ed3\u5e93_-_git_remote_add\" style=\"color:#50585D;font-weight:500;font-size:1.4em;font-family:&quot;background-color:#FFFFFF;\">\n\t1.\u94fe\u63a5\u8fdc\u7aef\u4ed3\u5e93 - git remote add<br \/>\n<\/h3>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u4e3a\u4e86\u80fd\u591f\u4e0a\u4f20\u5230\u8fdc\u7aef\u4ed3\u5e93\uff0c\u6211\u4eec\u9700\u8981\u5148\u5efa\u7acb\u8d77\u94fe\u63a5\uff0c\u8fd9\u7bc7\u6559\u7a0b\u4e2d\uff0c\u8fdc\u7aef\u4ed3\u5e93\u7684\u5730\u5740\u4e3a\uff1a<a href=\"https:\/\/github.com\/tutorialzine\/awesome-project,%E4%BD%86%E4%BD%A0%E5%BA%94%E8%AF%A5%E8%87%AA%E5%B7%B1%E5%9C%A8Github\" target=\"_blank\">https:\/\/github.com\/tutorialzine\/awesome-project,\u4f46\u4f60\u5e94\u8be5\u81ea\u5df1\u5728Github<\/a>, BitBucket\u4e0a\u642d\u5efa\u4ed3\u5e93\uff0c\u81ea\u5df1\u4e00\u6b65\u4e00\u6b65\u5c1d\u8bd5\u3002\n<\/p>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u6dfb\u52a0\u6d4b\u8bd5\u7528\u7684\u8fdc\u7aef\u4ed3\u5e93\n<\/p>\n<div class=\"highlight-wrap\" style=\"background:#eeeeee;color:#444444;font-family:&quot;font-size:18px;\">\n<table style=\"margin:0px;border:none;padding:10px;width:auto;\">\n<tbody>\n<tr>\n<td class=\"code\" style=\"border:none;\">\n<pre><span class=\"line\">$ git remote add origin https:\/\/github.com\/tutorialzine\/awesome-project.git<\/span> <\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u4e00\u4e2a\u9879\u76ee\u53ef\u4ee5\u540c\u65f6\u62e5\u6709\u597d\u51e0\u4e2a\u8fdc\u7aef\u4ed3\u5e93\u4e3a\u4e86\u80fd\u591f\u533a\u5206\uff0c\u901a\u5e38\u4f1a\u8d77\u4e0d\u540c\u7684\u540d\u5b57\u3002\u901a\u5e38\u4e3b\u8fdc\u7aef\u4ed3\u5e93\u88ab\u79f0\u4e3aorigin\u3002\n<\/p>\n<h3 id=\"2-\u4e0a\u4f20\u5230\u670d\u52a1\u5668_-_git_push\" style=\"color:#50585D;font-weight:500;font-size:1.4em;font-family:&quot;background-color:#FFFFFF;\">\n\t2.\u4e0a\u4f20\u5230\u670d\u52a1\u5668 - git push<br \/>\n<\/h3>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u6bcf\u6b21\u6211\u4eec\u8981\u63d0\u4ea4\u4ee3\u7801\u5230\u670d\u52a1\u5668\u4e0a\u65f6\uff0c\u90fd\u4f1a\u4f7f\u7528\u5230git push\u3002\n<\/p>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\tgit push\u547d\u4ee4\u4f1a\u6709\u4e24\u4e2a\u53c2\u6570\uff0c\u8fdc\u7aef\u4ed3\u5e93\u7684\u540d\u5b57\uff0c\u4ee5\u53ca\u5206\u652f\u7684\u540d\u5b57\uff1a\n<\/p>\n<div class=\"highlight-wrap\" style=\"background:#eeeeee;color:#444444;font-family:&quot;font-size:18px;\">\n<table style=\"margin:0px;border:none;padding:10px;width:auto;\">\n<tbody>\n<tr>\n<td class=\"code\" style=\"border:none;\">\n<pre><span class=\"line\">$ git push origin master\r\n\r\nCounting objects: 3, done.\r\nWriting objects: 100% (3\/3), 212 bytes | 0 bytes\/s, done.\r\nTotal 3 (delta 0), reused 0 (delta 0)\r\nTo https:\/\/github.com\/tutorialzine\/awesome-project.git\r\n * [new branch]      master -&gt; master<\/span> <\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u53d6\u51b3\u4e8e\u4f60\u4f7f\u7528\u7684\u670d\u52a1\u5668\uff0cpush\u8fc7\u7a0b\u4f60\u53ef\u80fd\u9700\u8981\u9a8c\u8bc1\u8eab\u4efd\u3002\u5982\u679c\u6ca1\u6709\u51fa\u5dee\u9519\uff0c\u73b0\u5728\u4f7f\u7528\u6d4f\u89c8\u5668\u53bb\u4f60\u7684\u8fdc\u7aef\u5206\u652f\u4e0a\u770b\uff0chello.txt\u5df2\u7ecf\u5728\u90a3\u91cc\u7b49\u7740\u4f60\u4e86\u3002\n<\/p>\n<h3 id=\"3-\u514b\u9686\u4ed3\u5e93_-_git_clone\" style=\"color:#50585D;font-weight:500;font-size:1.4em;font-family:&quot;background-color:#FFFFFF;\">\n\t3.\u514b\u9686\u4ed3\u5e93 - git clone<br \/>\n<\/h3>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u653e\u5728Github\u4e0a\u7684\u5f00\u6e90\u9879\u76ee\uff0c\u4eba\u4eec\u53ef\u4ee5\u770b\u5230\u4f60\u7684\u4ee3\u7801\u3002\u53ef\u4ee5\u4f7f\u7528 git clone\u8fdb\u884c\u4e0b\u8f7d\u5230\u672c\u5730\u3002\n<\/p>\n<div class=\"highlight-wrap\" style=\"background:#eeeeee;color:#444444;font-family:&quot;font-size:18px;\">\n<table style=\"margin:0px;border:none;padding:10px;width:auto;\">\n<tbody>\n<tr>\n<td class=\"code\" style=\"border:none;\">\n<pre><span class=\"line\">$ git clone https:\/\/github.com\/tutorialzine\/awesome-project.git<\/span> <\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u672c\u5730\u4e5f\u4f1a\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u4ed3\u5e93\uff0c\u5e76\u81ea\u52a8\u5c06github\u4e0a\u7684\u5206\u652f\u8bbe\u4e3a\u8fdc\u7aef\u5206\u652f\u3002\n<\/p>\n<h3 id=\"4-\u4ece\u670d\u52a1\u5668\u4e0a\u62c9\u53d6\u4ee3\u7801_-_git_pull\" style=\"color:#50585D;font-weight:500;font-size:1.4em;font-family:&quot;background-color:#FFFFFF;\">\n\t4.\u4ece\u670d\u52a1\u5668\u4e0a\u62c9\u53d6\u4ee3\u7801 - git pull<br \/>\n<\/h3>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u5982\u679c\u4f60\u66f4\u65b0\u4e86\u4ee3\u7801\u5230\u4ed3\u5e93\u4e0a\uff0c\u5176\u4ed6\u4eba\u53ef\u4ee5\u901a\u8fc7git pull\u547d\u4ee4\u62c9\u53d6\u4f60\u7684\u53d8\u52a8\uff1a\n<\/p>\n<div class=\"highlight-wrap\" style=\"background:#eeeeee;color:#444444;font-family:&quot;font-size:18px;\">\n<table style=\"margin:0px;border:none;padding:10px;width:auto;\">\n<tbody>\n<tr>\n<td class=\"code\" style=\"border:none;\">\n<pre><span class=\"line\">$ git pull origin master\r\nFrom https:\/\/github.com\/tutorialzine\/awesome-project\r\n * branch            master     -&gt; FETCH_HEAD\r\nAlready up-to-date.<\/span> <\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u56e0\u4e3a\u6682\u65f6\u6ca1\u6709\u5176\u4ed6\u4eba\u63d0\u4ea4\uff0c\u6240\u6709\u6ca1\u6709\u4efb\u4f55\u53d8\u52a8\n<\/p>\n<h2 id=\"\u5206\u652f\" style=\"color:#50585D;font-weight:500;font-size:1.6em;font-family:&quot;background-color:#FFFFFF;\">\n\t\u5206\u652f<br \/>\n<\/h2>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t<a href=\"http:\/\/7xirra.com1.z0.glb.clouddn.com\/learn-git-in-30-minutes-branch.jpg\" class=\"fancybox\"><img decoding=\"async\" src=\"http:\/\/7xirra.com1.z0.glb.clouddn.com\/learn-git-in-30-minutes-branch.jpg\" alt=\"branchs\" \/><\/a>\n<\/p>\n<div class=\"fancybox__caption\" style=\"text-align:center;font-size:14px;\">\n\tbranchs\n<\/div>\n<p>\n\u5f53\u4f60\u5728\u505a\u4e00\u4e2a\u65b0\u529f\u80fd\u7684\u65f6\u5019\uff0c\u6700\u597d\u662f\u5728\u4e00\u4e2a\u72ec\u7acb\u7684\u533a\u57df\u4e0a\u5f00\u53d1\uff0c\u901a\u5e38\u79f0\u4e4b\u4e3a\u5206\u652f\u3002\u5206\u652f\u4e4b\u95f4\u76f8\u4e92\u72ec\u7acb\uff0c\u5e76\u4e14\u62e5\u6709\u81ea\u5df1\u7684\u5386\u53f2\u8bb0\u5f55\u3002\u8fd9\u6837\u505a\u7684\u539f\u56e0\u662f\uff1a<\/p>\n<ul style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n<li>\n\t\t\u7a33\u5b9a\u7248\u672c\u7684\u4ee3\u7801\u4e0d\u4f1a\u88ab\u7834\u574f\n\t<\/li>\n<li>\n\t\t\u4e0d\u540c\u7684\u529f\u80fd\u53ef\u4ee5\u7531\u4e0d\u540c\u5f00\u53d1\u8005\u540c\u65f6\u5f00\u53d1\u3002\n\t<\/li>\n<li>\n\t\t\u5f00\u53d1\u8005\u53ef\u4ee5\u4e13\u6ce8\u4e8e\u81ea\u5df1\u7684\u5206\u652f\uff0c\u4e0d\u7528\u62c5\u5fc3\u88ab\u5176\u4ed6\u4eba\u7834\u574f\u4e86\u73af\u5883\n\t<\/li>\n<li>\n\t\t\u5728\u4e0d\u786e\u5b9a\u4e4b\u524d\uff0c\u540c\u4e00\u4e2a\u7279\u6027\u53ef\u4ee5\u62e5\u6709\u51e0\u4e2a\u7248\u672c\uff0c\u4fbf\u4e8e\u6bd4\u8f83\n\t<\/li>\n<\/ul>\n<h3 id=\"1-\u521b\u5efa\u65b0\u5206\u652f_-_git_branch\" style=\"color:#50585D;font-weight:500;font-size:1.4em;font-family:&quot;background-color:#FFFFFF;\">\n\t1.\u521b\u5efa\u65b0\u5206\u652f - git branch<br \/>\n<\/h3>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u6bcf\u4e00\u4e2a\u4ed3\u5e93\u7684\u9ed8\u8ba4\u5206\u652f\u90fd\u53ebmaster, \u521b\u5efa\u65b0\u5206\u652f\u53ef\u4ee5\u8fd9\u6837\uff1a\n<\/p>\n<div class=\"highlight-wrap\" style=\"background:#eeeeee;color:#444444;font-family:&quot;font-size:18px;\">\n<table style=\"margin:0px;border:none;padding:10px;width:auto;\">\n<tbody>\n<tr>\n<td class=\"code\" style=\"border:none;\">\n<pre><span class=\"line\">$ git branch amazing_new_feature<\/span> <\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u521b\u5efa\u4e86\u4e00\u4e2a\u540d\u4e3aamazing_new_feature\u7684\u65b0\u5206\u652f\uff0c\u5b83\u8ddf\u5f53\u524d\u5206\u652f\u540c\u4e00\u8d77\u70b9\n<\/p>\n<h3 id=\"2-\u5207\u6362\u5206\u652f_-_git_checkout\" style=\"color:#50585D;font-weight:500;font-size:1.4em;font-family:&quot;background-color:#FFFFFF;\">\n\t2.\u5207\u6362\u5206\u652f - git checkout<br \/>\n<\/h3>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u5355\u72ec\u4f7f\u7528git branch\uff0c\u53ef\u4ee5\u67e5\u770b\u5206\u652f\u72b6\u6001\uff1a\n<\/p>\n<div class=\"highlight-wrap\" style=\"background:#eeeeee;color:#444444;font-family:&quot;font-size:18px;\">\n<table style=\"margin:0px;border:none;padding:10px;width:auto;\">\n<tbody>\n<tr>\n<td class=\"code\" style=\"border:none;\">\n<pre><span class=\"line\">$ git branch\r\n  amazing_new_feature\r\n* master<\/span> <\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t*&nbsp;\u53f7\u8868\u793a\u5f53\u524d\u6d3b\u8dc3\u5206\u652f\u4e3amaster\uff0c\u4f7f\u7528git checkout\u5207\u6362\u5206\u652f\u3002\n<\/p>\n<div class=\"highlight-wrap\" style=\"background:#eeeeee;color:#444444;font-family:&quot;font-size:18px;\">\n<table style=\"margin:0px;border:none;padding:10px;width:auto;\">\n<tbody>\n<tr>\n<td class=\"code\" style=\"border:none;\">\n<pre><span class=\"line\">$ git checkout amazing_new_feature<\/span> <\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h3 id=\"3-\u5408\u5e76\u5206\u652f_-_git_merge\" style=\"color:#50585D;font-weight:500;font-size:1.4em;font-family:&quot;background-color:#FFFFFF;\">\n\t3.\u5408\u5e76\u5206\u652f - git merge<br \/>\n<\/h3>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u6211\u4eec\u7684 amazing_new_feature \u5206\u652f\u7684\u4efb\u52a1\u662f\u589e\u52a0\u4e00\u4e2afeatuer.txt\u3002\u6211\u4eec\u6765\u521b\u5efa\uff0c\u6dfb\u52a0\u5230\u6682\u5b58\u533a\uff0c\u63d0\u4ea4\u3002\n<\/p>\n<div class=\"highlight-wrap\" style=\"background:#eeeeee;color:#444444;font-family:&quot;font-size:18px;\">\n<table style=\"margin:0px;border:none;padding:10px;width:auto;\">\n<tbody>\n<tr>\n<td class=\"code\" style=\"border:none;\">\n<pre><span class=\"line\">$ git add feature.txt\r\n$ git commit -m \"New feature complete.\"<\/span> <\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u65b0\u5206\u652f\u4efb\u52a1\u5b8c\u6210\u4e86\uff0c\u56de\u5230master\u5206\u652f\n<\/p>\n<div class=\"highlight-wrap\" style=\"background:#eeeeee;color:#444444;font-family:&quot;font-size:18px;\">\n<table style=\"margin:0px;border:none;padding:10px;width:auto;\">\n<tbody>\n<tr>\n<td class=\"code\" style=\"border:none;\">\n<pre><span class=\"line\">$ git checkout master<\/span> <\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u73b0\u5728\u53bb\u67e5\u770b\u6587\u4ef6\uff0c\u4f60\u4f1a\u53d1\u73b0\uff0c\u4e4b\u524d\u521b\u5efa\u7684feature.txt\u6587\u4ef6\u4e0d\u89c1\u4e86\uff0c\u56e0\u4e3amaster\u5206\u652f\u4e0a\u5e76\u6ca1\u6709feature.txt\u3002\u4f7f\u7528git merge \u628a amazing_new_feature \u5206\u652f\u5408\u5e76\u5230master\u4e0a\u3002\n<\/p>\n<div class=\"highlight-wrap\" style=\"background:#eeeeee;color:#444444;font-family:&quot;font-size:18px;\">\n<table style=\"margin:0px;border:none;padding:10px;width:auto;\">\n<tbody>\n<tr>\n<td class=\"code\" style=\"border:none;\">\n<pre><span class=\"line\">$ git merge amazing_new_feature<\/span> <\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\tok! \u7136\u540e\u518d\u628aamazing_new_feature \u5206\u652f\u5220\u6389\u5427\u3002\n<\/p>\n<div class=\"highlight-wrap\" style=\"background:#eeeeee;color:#444444;font-family:&quot;font-size:18px;\">\n<table style=\"margin:0px;border:none;padding:10px;width:auto;\">\n<tbody>\n<tr>\n<td class=\"code\" style=\"border:none;\">\n<pre><span class=\"line\">$ git branch -d amazing_new_feature<\/span> <\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h2 id=\"\u9ad8\u7ea7\" style=\"color:#50585D;font-weight:500;font-size:1.6em;font-family:&quot;background-color:#FFFFFF;\">\n\t\u9ad8\u7ea7<br \/>\n<\/h2>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u8fd9\u7bc7\u6587\u7ae0\u7684\u6700\u540e\u4e00\u8282\uff0c\u6211\u4eec\u6765\u8bf4\u4e9b\u6bd4\u8f83\u9ad8\u7ea7\u5e76\u4e14\u4f7f\u7528\u7684\u6280\u5de7\u3002\n<\/p>\n<h3 id=\"1-\u6bd4\u5bf9\u4e24\u4e2a\u4e0d\u540c\u63d0\u4ea4\u4e4b\u95f4\u7684\u5dee\u522b\" style=\"color:#50585D;font-weight:500;font-size:1.4em;font-family:&quot;background-color:#FFFFFF;\">\n\t1.\u6bd4\u5bf9\u4e24\u4e2a\u4e0d\u540c\u63d0\u4ea4\u4e4b\u95f4\u7684\u5dee\u522b<br \/>\n<\/h3>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u6bcf\u6b21\u63d0\u4ea4\u90fd\u6709\u4e00\u4e2a\u552f\u4e00id\uff0c\u67e5\u770b\u6240\u6709\u63d0\u4ea4\u548c\u4ed6\u4eec\u7684id\uff0c\u53ef\u4ee5\u4f7f\u7528 git log:\n<\/p>\n<div class=\"highlight-wrap\" style=\"background:#eeeeee;color:#444444;font-family:&quot;font-size:18px;\">\n<table style=\"margin:0px;border:none;padding:10px;width:auto;\">\n<tbody>\n<tr>\n<td class=\"code\" style=\"border:none;\">\n<pre><span class=\"line\">$ git log\r\n\r\ncommit ba25c0ff30e1b2f0259157b42b9f8f5d174d80d7\r\nAuthor: Tutorialzine\r\nDate:   Mon May 30 17:15:28 2016 +0300\r\n\r\n    New feature complete\r\n\r\ncommit b10cc1238e355c02a044ef9f9860811ff605c9b4\r\nAuthor: Tutorialzine\r\nDate:   Mon May 30 16:30:04 2016 +0300\r\n\r\n    Added content to hello.txt\r\n\r\ncommit 09bd8cc171d7084e78e4d118a2346b7487dca059\r\nAuthor: Tutorialzine\r\nDate:   Sat May 28 17:52:14 2016 +0300\r\n\r\n    Initial commit<\/span> <\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\tid \u5f88\u957f\uff0c\u4f46\u662f\u4f60\u5e76\u4e0d\u9700\u8981\u590d\u5236\u6574\u4e2a\u5b57\u7b26\u4e32\uff0c\u524d\u4e00\u5c0f\u90e8\u5206\u5c31\u591f\u4e86\u3002<br \/>\n\u67e5\u770b\u67d0\u4e00\u6b21\u63d0\u4ea4\u66f4\u65b0\u4e86\u4ec0\u4e48\uff0c\u4f7f\u7528 git show:\n<\/p>\n<div class=\"highlight-wrap\" style=\"background:#eeeeee;color:#444444;font-family:&quot;font-size:18px;\">\n<table style=\"margin:0px;border:none;padding:10px;width:auto;\">\n<tbody>\n<tr>\n<td class=\"code\" style=\"border:none;\">\n<pre><span class=\"line\">$ git show b10cc123\r\n\r\ncommit b10cc1238e355c02a044ef9f9860811ff605c9b4\r\nAuthor: Tutorialzine\r\nDate:   Mon May 30 16:30:04 2016 +0300\r\n\r\n    Added content to hello.txt\r\n\r\ndiff --git a\/hello.txt b\/hello.txt\r\nindex e69de29..b546a21 100644\r\n--- a\/hello.txt\r\n+++ b\/hello.txt\r\n@@ -0,0 +1 @@\r\n+Nice weather today, isn't it?<\/span> <\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u67e5\u770b\u4e24\u6b21\u63d0\u4ea4\u7684\u4e0d\u540c\uff0c\u53ef\u4ee5\u4f7f\u7528git diff [commit-from]..[commit-to] \u8bed\u6cd5\uff1a\n<\/p>\n<div class=\"highlight-wrap\" style=\"background:#eeeeee;color:#444444;font-family:&quot;font-size:18px;\">\n<table style=\"margin:0px;border:none;padding:10px;width:auto;\">\n<tbody>\n<tr>\n<td class=\"code\" style=\"border:none;\">\n<pre><span class=\"line\">$ git diff 09bd8cc..ba25c0ff\r\n\r\ndiff --git a\/feature.txt b\/feature.txt\r\nnew file mode 100644\r\nindex 0000000..e69de29\r\ndiff --git a\/hello.txt b\/hello.txt\r\nindex e69de29..b546a21 100644\r\n--- a\/hello.txt\r\n+++ b\/hello.txt\r\n@@ -0,0 +1 @@\r\n+Nice weather today, isn't it?<\/span> <\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u6bd4\u8f83\u9996\u6b21\u63d0\u4ea4\u548c\u6700\u540e\u4e00\u6b21\u63d0\u4ea4\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u6240\u6709\u7684\u66f4\u6539\u3002\u5f53\u7136\u4f7f\u7528git difftool\u547d\u4ee4\u66f4\u52a0\u65b9\u4fbf\u3002\n<\/p>\n<h3 id=\"2-\u56de\u6eda\u67d0\u4e2a\u6587\u4ef6\u5230\u4e4b\u524d\u7684\u7248\u672c\" style=\"color:#50585D;font-weight:500;font-size:1.4em;font-family:&quot;background-color:#FFFFFF;\">\n\t2.\u56de\u6eda\u67d0\u4e2a\u6587\u4ef6\u5230\u4e4b\u524d\u7684\u7248\u672c<br \/>\n<\/h3>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\tgit \u5141\u8bb8\u6211\u4eec\u5c06\u67d0\u4e2a\u7279\u5b9a\u7684\u6587\u4ef6\u56de\u6eda\u5230\u7279\u5b9a\u7684\u63d0\u4ea4\uff0c\u4f7f\u7528\u7684\u4e5f\u662f git checkout\u3002\n<\/p>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u4e0b\u9762\u7684\u4f8b\u5b50\uff0c\u6211\u4eec\u5c06hello.txt\u56de\u6eda\u5230\u6700\u521d\u7684\u72b6\u6001\uff0c\u9700\u8981\u6307\u5b9a\u56de\u6eda\u5230\u54ea\u4e2a\u63d0\u4ea4\uff0c\u4ee5\u53ca\u6587\u4ef6\u7684\u5168\u8def\u5f84\u3002\n<\/p>\n<div class=\"highlight-wrap\" style=\"background:#eeeeee;color:#444444;font-family:&quot;font-size:18px;\">\n<table style=\"margin:0px;border:none;padding:10px;width:auto;\">\n<tbody>\n<tr>\n<td class=\"code\" style=\"border:none;\">\n<pre><span class=\"line\">$ git checkout 09bd8cc1 hello.txt<\/span> <\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h3 id=\"3-\u56de\u6eda\u63d0\u4ea4\" style=\"color:#50585D;font-weight:500;font-size:1.4em;font-family:&quot;background-color:#FFFFFF;\">\n\t3.\u56de\u6eda\u63d0\u4ea4<br \/>\n<\/h3>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u5982\u679c\u4f60\u53d1\u73b0\u6700\u65b0\u7684\u4e00\u6b21\u63d0\u4ea4\u5b8c\u4e86\u52a0\u67d0\u4e2a\u6587\u4ef6\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7 git commit \u2014amend\u6765\u4fee\u590d\uff0c\u5b83\u4f1a\u628a\u6700\u65b0\u7684\u63d0\u4ea4\u6253\u56de\u6682\u5b58\u533a\uff0c\u5e76\u5c1d\u8bd5\u91cd\u65b0\u63d0\u4ea4\u3002\n<\/p>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u5982\u679c\u662f\u66f4\u590d\u6742\u7684\u60c5\u51b5\uff0c\u6bd4\u5982\u4e0d\u662f\u6700\u65b0\u7684\u63d0\u4ea4\u4e86\u3002\u90a3\u4f60\u53ef\u4ee5\u4f7f\u7528git revert\u3002\n<\/p>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u6700\u65b0\u7684\u4e00\u6b21\u63d0\u4ea4\u522b\u540d\u4e5f\u53ebHEAD\u3002\n<\/p>\n<div class=\"highlight-wrap\" style=\"background:#eeeeee;color:#444444;font-family:&quot;font-size:18px;\">\n<table style=\"margin:0px;border:none;padding:10px;width:auto;\">\n<tbody>\n<tr>\n<td class=\"code\" style=\"border:none;\">\n<pre><span class=\"line\">$ git revert HEAD<\/span> <\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u5176\u4ed6\u63d0\u4ea4\u53ef\u4ee5\u4f7f\u7528id:\n<\/p>\n<div class=\"highlight-wrap\" style=\"background:#eeeeee;color:#444444;font-family:&quot;font-size:18px;\">\n<table style=\"margin:0px;border:none;padding:10px;width:auto;\">\n<tbody>\n<tr>\n<td class=\"code\" style=\"border:none;\">\n<pre><span class=\"line\">$ git revert b10cc123<\/span> <\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u6df7\u6eda\u63d0\u4ea4\u65f6\uff0c\u53d1\u751f\u51b2\u7a81\u662f\u975e\u5e38\u9891\u7e41\u7684\u3002\u5f53\u6587\u4ef6\u88ab\u540e\u9762\u7684\u63d0\u4ea4\u4fee\u6539\u4e86\u4ee5\u540e\uff0cgit\u4e0d\u80fd\u6b63\u786e\u56de\u6eda\u3002\n<\/p>\n<h3 id=\"4-\u89e3\u51b3\u5408\u5e76\u51b2\u7a81\" style=\"color:#50585D;font-weight:500;font-size:1.4em;font-family:&quot;background-color:#FFFFFF;\">\n\t4.\u89e3\u51b3\u5408\u5e76\u51b2\u7a81<br \/>\n<\/h3>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u51b2\u7a81\u7ecf\u5e38\u51fa\u73b0\u5728\u5408\u5e76\u5206\u652f\u6216\u8005\u662f\u62c9\u53bb\u522b\u4eba\u7684\u4ee3\u7801\u3002\u6709\u4e9b\u65f6\u5019git\u80fd\u81ea\u52a8\u5904\u7406\u51b2\u7a81\uff0c\u4f46\u5927\u90e8\u5206\u9700\u8981\u6211\u4eec\u624b\u52a8\u5904\u7406\u3002\n<\/p>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u6bd4\u5982John \u548c Tim \u5206\u522b\u5728\u5404\u81ea\u7684\u5206\u652f\u4e0a\u5199\u4e86\u4e24\u90e8\u5206\u4ee3\u7801\u3002<br \/>\nJohn \u559c\u6b22 for:\n<\/p>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\/\/ Use a for loop to console.log contents.<br \/>\nfor(var i=0; i&lt;arr.length; i++) {<br \/>\nconsole.log(arr[i]);<br \/>\n}<br \/>\nTim \u559c\u6b22 forEach:\n<\/p>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\/\/ Use forEach to console.log contents.<br \/>\narr.forEach(function(item) {<br \/>\nconsole.log(item);<br \/>\n});\n<\/p>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u5047\u8bbeJohn \u73b0\u5728\u53bb\u62c9\u53d6 Tim\u7684\u4ee3\u7801:\n<\/p>\n<div class=\"highlight-wrap\" style=\"background:#eeeeee;color:#444444;font-family:&quot;font-size:18px;\">\n<table style=\"margin:0px;border:none;padding:10px;width:auto;\">\n<tbody>\n<tr>\n<td class=\"code\" style=\"border:none;\">\n<pre><span class=\"line\">$ git merge tim_branch\r\n\r\nAuto-merging print_array.js\r\nCONFLICT (content): Merge conflict in print_array.js\r\nAutomatic merge failed; fix conflicts and then commit the result.<\/span> <\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u8fd9\u65f6\u5019git\u5e76\u4e0d\u77e5\u9053\u5982\u4f55\u89e3\u51b3\u51b2\u7a81\uff0c\u56e0\u4e3a\u4ed6\u4e0d\u77e5\u9053John\u548cTim\u8c01\u5199\u5f97\u66f4\u597d\u3002\n<\/p>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u4e8e\u662f\u5b83\u5c31\u5728\u4ee3\u7801\u4e2d\u63d2\u5165\u6807\u8bb0\u3002\n<\/p>\n<div class=\"highlight-wrap\" style=\"background:#eeeeee;color:#444444;font-family:&quot;font-size:18px;\">\n<table style=\"margin:0px;border:none;padding:10px;width:auto;\">\n<tbody>\n<tr>\n<td class=\"code\" style=\"border:none;\">\n<pre><span class=\"line\">&lt;&lt;<span class=\"xml\"><span class=\"tag\" style=\"color:#F2777A;\">&lt;&lt;&lt;&lt;&lt; <span class=\"attribute\">HEAD<\/span><\/span> <span class=\"line\">\/\/ <span class=\"attribute\" style=\"color:#F2777A;\">Use<\/span> <span class=\"attribute\" style=\"color:#F2777A;\">a<\/span> <span class=\"attribute\" style=\"color:#F2777A;\">for<\/span> <span class=\"attribute\" style=\"color:#F2777A;\">loop<\/span> <span class=\"attribute\" style=\"color:#F2777A;\">to<\/span> <span class=\"attribute\" style=\"color:#F2777A;\">console.log<\/span> <span class=\"attribute\" style=\"color:#F2777A;\">contents.<\/span><\/span> <span class=\"line\"><span class=\"attribute\" style=\"color:#F2777A;\">for<\/span>(<span class=\"attribute\" style=\"color:#F2777A;\">var<\/span> <span class=\"attribute\" style=\"color:#F2777A;\">i<\/span>=<span class=\"value\" style=\"color:#99CC99;\">0;<\/span> <span class=\"attribute\" style=\"color:#F2777A;\">i<\/span>&lt;<span class=\"attribute\" style=\"color:#F2777A;\">arr.length<\/span>; <span class=\"attribute\" style=\"color:#F2777A;\">i<\/span>++) {<\/span> <span class=\"line\"> <span class=\"attribute\" style=\"color:#F2777A;\">console.log<\/span>(<span class=\"attribute\" style=\"color:#F2777A;\">arr<\/span>[<span class=\"attribute\" style=\"color:#F2777A;\">i<\/span>]);<\/span> <span class=\"line\">}<\/span> <span class=\"line\">=<span class=\"value\" style=\"color:#99CC99;\">======<\/span><\/span> <span class=\"line\">\/\/ <span class=\"attribute\" style=\"color:#F2777A;\">Use<\/span> <span class=\"attribute\" style=\"color:#F2777A;\">forEach<\/span> <span class=\"attribute\" style=\"color:#F2777A;\">to<\/span> <span class=\"attribute\" style=\"color:#F2777A;\">console.log<\/span> <span class=\"attribute\" style=\"color:#F2777A;\">contents.<\/span><\/span> <span class=\"line\"><span class=\"attribute\" style=\"color:#F2777A;\">arr.forEach<\/span>(<span class=\"attribute\" style=\"color:#F2777A;\">function<\/span>(<span class=\"attribute\" style=\"color:#F2777A;\">item<\/span>) {<\/span> <span class=\"line\"> <span class=\"attribute\" style=\"color:#F2777A;\">console.log<\/span>(<span class=\"attribute\" style=\"color:#F2777A;\">item<\/span>);<\/span> <span class=\"line\">});<\/span> <span class=\"line\">&gt;<\/span>&gt;&gt;&gt;&gt;&gt;&gt; Tim s commit.<\/span><\/span> <\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t==== \u53f7\u4e0a\u65b9\u662f\u5f53\u524d\u6700\u65b0\u4e00\u6b21\u63d0\u4ea4\uff0c\u4e0b\u65b9\u662f\u51b2\u7a81\u7684\u4ee3\u7801\u3002\u6211\u4eec\u9700\u8981\u89e3\u51b3\u8fd9\u6837\u7684\u51b2\u7a81\uff0c\u7ecf\u8fc7\u7ec4\u59d4\u4f1a\u6210\u5458\u8ba8\u8bba\uff0c\u4e00\u81f4\u8ba4\u5b9a\uff0c\u5728\u5ea7\u7684\u5404\u4f4d\u90fd\u662f\u5783\u573e\uff01\u4e24\u4e2a\u90fd\u4e0d\u8981\u3002\u6539\u6210\u4e0b\u9762\u7684\u4ee3\u7801\u3002\n<\/p>\n<div class=\"highlight-wrap\" style=\"background:#eeeeee;color:#444444;font-family:&quot;font-size:18px;\">\n<table style=\"margin:0px;border:none;padding:10px;width:auto;\">\n<tbody>\n<tr>\n<td class=\"code\" style=\"border:none;\">\n<pre><span class=\"line\">\/\/ Not using for loop or forEach.\r\n\/\/ Use Array.toString() to console.log contents.\r\nconsole.log(arr.toString());<\/span> <\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u597d\u4e86\uff0c\u518d\u63d0\u4ea4\u4e00\u4e0b\uff1a\n<\/p>\n<div class=\"highlight-wrap\" style=\"background:#eeeeee;color:#444444;font-family:&quot;font-size:18px;\">\n<table style=\"margin:0px;border:none;padding:10px;width:auto;\">\n<tbody>\n<tr>\n<td class=\"code\" style=\"border:none;\">\n<pre><span class=\"line\">$ git add -A\r\n$ git commit -m \"Array printing conflict resolved.\"<\/span> <\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u5982\u679c\u5728\u5927\u578b\u9879\u76ee\u4e2d\uff0c\u8fd9\u4e2a\u8fc7\u7a0b\u53ef\u80fd\u5bb9\u6613\u51fa\u95ee\u9898\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528<a href=\"https:\/\/git-scm.com\/download\/gui\/linux\" target=\"_blank\">GUI \u5de5\u5177<\/a>\u6765\u5e2e\u52a9\u4f60\u3002\u4f7f\u7528 git mergetool\u3002\n<\/p>\n<h3 id=\"5-\u914d\u7f6e_-gitignore\" style=\"color:#50585D;font-weight:500;font-size:1.4em;font-family:&quot;background-color:#FFFFFF;\">\n\t5.\u914d\u7f6e .gitignore<br \/>\n<\/h3>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u5927\u90e8\u5206\u9879\u76ee\u4e2d\uff0c\u4f1a\u6709\u5199\u6587\u4ef6\uff0c\u6587\u4ef6\u5939\u662f\u6211\u4eec\u4e0d\u60f3\u63d0\u4ea4\u7684\u3002\u4e3a\u4e86\u9632\u6b62\u4e00\u4e0d\u5c0f\u5fc3\u63d0\u4ea4\uff0c\u6211\u4eec\u9700\u8981gitignore\u6587\u4ef6\uff1a\n<\/p>\n<ol style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n<li>\n\t\t\u5728\u9879\u76ee\u6839\u76ee\u5f55\u521b\u5efa.gitignore\u6587\u4ef6\n\t<\/li>\n<li>\n\t\t\u5728\u6587\u4ef6\u4e2d\u5217\u51fa\u4e0d\u9700\u8981\u63d0\u4ea4\u7684\u6587\u4ef6\u540d\uff0c\u6587\u4ef6\u5939\u540d\uff0c\u6bcf\u4e2a\u4e00\u884c\n\t<\/li>\n<li>\n\t\t.gitignore\u6587\u4ef6\u9700\u8981\u63d0\u4ea4\uff0c\u5c31\u50cf\u666e\u901a\u6587\u4ef6\u4e00\u6837\n\t<\/li>\n<\/ol>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u901a\u5e38\u4f1a\u88abignore\u7684\u6587\u4ef6\u6709\uff1a\n<\/p>\n<ul style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n<li>\n\t\tlog\u6587\u4ef6\n\t<\/li>\n<li>\n\t\ttask runner builds\n\t<\/li>\n<li>\n\t\tnode_modules\u7b49\u6587\u4ef6\u5939\n\t<\/li>\n<li>\n\t\tIDEs\u751f\u6210\u7684\u6587\u4ef6\n\t<\/li>\n<li>\n\t\t\u4e2a\u4eba\u7b14\u8bb0\n\t<\/li>\n<\/ul>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u4f8b\u5982\uff1a\n<\/p>\n<div class=\"highlight-wrap\" style=\"background:#eeeeee;color:#444444;font-family:&quot;font-size:18px;\">\n<table style=\"margin:0px;border:none;padding:10px;width:auto;\">\n<tbody>\n<tr>\n<td class=\"code\" style=\"border:none;\">\n<pre><span class=\"line\">*.log\r\nbuild\/\r\nnode_modules\/\r\n.idea\/\r\nmy_notes.txt<\/span> <\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h2 id=\"\u603b\u7ed3\" style=\"color:#50585D;font-weight:500;font-size:1.6em;font-family:&quot;background-color:#FFFFFF;\">\n\t\u603b\u7ed3<br \/>\n<\/h2>\n<p style=\"color:#444444;font-family:&quot;font-size:18px;background-color:#FFFFFF;\">\n\t\u6559\u7a0b\u7ed3\u675f~(\u6492\u82b1)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u57fa\u672c\u4e86\u89e3 git\u547d\u4ee4\u662f\u4e00\u4e9b\u547d\u4ee4\u884c\u5de5\u5177\u7684\u96c6\u5408\uff0c\u5b83\u53ef\u4ee5\u7528\u6765\u8ddf\u8e2a\uff0c\u8bb0\u5f55\u6587\u4ef6\u7684\u53d8\u52a8\u3002\u6bd4\u5982\u4f60\u53ef\u4ee5\u8fdb\u884c\u4fdd\u5b58\uff0c\u6bd4\u5bf9\uff0c\u5206\u6790\uff0c\u5408\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.shuran.cn\/?p=710\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-710","post","type-post","status-publish","format-standard","hentry","category-other"],"_links":{"self":[{"href":"https:\/\/www.shuran.cn\/index.php?rest_route=\/wp\/v2\/posts\/710","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shuran.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shuran.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shuran.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shuran.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=710"}],"version-history":[{"count":1,"href":"https:\/\/www.shuran.cn\/index.php?rest_route=\/wp\/v2\/posts\/710\/revisions"}],"predecessor-version":[{"id":711,"href":"https:\/\/www.shuran.cn\/index.php?rest_route=\/wp\/v2\/posts\/710\/revisions\/711"}],"wp:attachment":[{"href":"https:\/\/www.shuran.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=710"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuran.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=710"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuran.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=710"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}