{"id":471,"date":"2020-01-13T11:07:46","date_gmt":"2020-01-13T03:07:46","guid":{"rendered":"https:\/\/www.caiqinyi.cn\/?p=471"},"modified":"2021-04-24T15:23:08","modified_gmt":"2021-04-24T07:23:08","slug":"git_existing_folder","status":"publish","type":"post","link":"https:\/\/www.caiqinyi.cn\/index.php\/2020\/01\/13\/git_existing_folder\/","title":{"rendered":"\u5728\u975e\u7a7a\u7684\u6587\u4ef6\u5939\u4e2d\u521b\u5efagit\u4ed3\u5e93"},"content":{"rendered":"<p>\u8bb0\u5f55\u4e00\u4e0b\u6bd4\u8f83\u6709\u7528\u7684\u6280\u5de7,\u56e0\u4e3a\u7ecf\u5e38\u60f3\u8981\u5728\u4e00\u4e2a\u975e\u7a7a\u7684\u6587\u4ef6\u5939\u4e2d\u521b\u5efagit\u4ed3\u5e93,\u4f46\u6bcf\u6b21\u90fd\u662f\u81ea\u5df1\u641e\u4e86\u4e2a\u7a7a\u7684\u6587\u4ef6\u5939\u53bb\u521b\u5efagit\u4ed3\u5e93,\u7136\u540e\u518d\u628a\u4e1c\u897f\u632a\u8fc7\u6765,\u663e\u5f97\u5f88\u4e0d\u4f18\u96c5\u2026\u2026<\/p>\n<p><!--more--><\/p>\n<p>Git\u5168\u5c40\u8bbe\u7f6e<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"C++\" data-enlighter-theme=\"monokai\">\r\ngit config --global user.name \"XXX\"\r\ngit config --global user.email \"XXX@YYY.com\"\r\n<\/pre>\n<p>\u521b\u5efa\u65b0\u7248\u672c\u5e93<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"C++\" data-enlighter-theme=\"monokai\">\r\ngit clone http:\/\/XXX.git\r\ncd XXX\r\ntouch README.md\r\ngit add README.md\r\ngit commit -m \"add README\"\r\ngit push -u origin master\r\n<\/pre>\n<p>\u5df2\u5b58\u5728\u7684\u6587\u4ef6\u5939<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"C++\" data-enlighter-theme=\"monokai\">\r\ncd existing_folder\r\ngit init\r\ngit remote add origin http:\/\/XXX.git\r\ngit add .\r\ngit commit -m \"Initial commit\"\r\ngit push -u origin master\r\n<\/pre>\n<p>\u5df2\u5b58\u5728\u7684 Git \u7248\u672c\u5e93<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"C++\" data-enlighter-theme=\"monokai\">\r\ncd existing_repo\r\ngit remote add origin http:\/\/XXX.git\r\ngit push -u origin --all\r\ngit push -u origin --tags\r\n<\/pre>\n<p>\u5f53\u7136, \u5982\u679c\u662f\u5728\u975e\u7a7a\u7684\u6587\u4ef6\u5939\u4e2d\u521b\u5efagit\u4ed3\u5e93, \u662f\u65e0\u6cd5\u76f4\u63a5\u5c06\u4f60\u5f53\u524d\u7684\u4ee3\u7801push\u5230master\u5206\u652f\u4e0a\u7684, \u6b64\u65f6\u53ef\u4ee5\u6267\u884c\u4e0b\u8ff0\u547d\u4ee4,<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"C++\" data-enlighter-theme=\"monokai\">\r\ngit pull --allow-unrelated-histories\r\n<\/pre>\n<p>\u9047\u5230\u65e0\u6cd5\u63d0\u4ea4\u7684\u95ee\u9898, \u4e00\u822c\u5148pull\u4e5f\u5c31\u662f\u4f7f\u7528git pull origin master, \u8fd9\u91cc\u7684origin\u5c31\u662f\u4ed3\u5e93, \u800cmaster\u5c31\u662f\u9700\u8981\u4e0a\u4f20\u7684\u5206\u652f, \u56e0\u4e3a\u4e24\u4e2a\u4ed3\u5e93\u4e0d\u540c, \u53d1\u73b0git\u8f93\u51farefusing to merge unrelated histories\u65e0\u6cd5pull\u5185\u5bb9.<\/p>\n<p>\u56e0\u4e3a\u4ed6\u4eec\u662f\u4e24\u4e2a\u4e0d\u540c\u7684\u9879\u76ee, \u8981\u628a\u4e24\u4e2a\u4e0d\u540c\u7684\u9879\u76ee\u5408\u5e76, git\u9700\u8981\u6dfb\u52a0\u4e00\u53e5\u4ee3\u7801, \u5728git pull\u4e4b\u540e, \u9700\u8981\u6dfb\u52a0&#8211;allow-unrelated-histories, \u544a\u8bc9git\u5141\u8bb8\u4e0d\u76f8\u5173\u5386\u53f2\u5408\u5e76.<\/p>\n<p>\u6216\u8005\u65b0\u5efa\u4e00\u4e2a\u5206\u652f, \u540e\u518d\u5207\u5230master\u5206\u652f\u4e0b\u6267\u884c\u5373\u53ef.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"C++\" data-enlighter-theme=\"monokai\">\r\ngit merge XXX\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u8bb0\u5f55\u4e00\u4e0b\u6bd4\u8f83\u6709\u7528\u7684\u6280\u5de7,\u56e0\u4e3a\u7ecf\u5e38\u60f3\u8981\u5728\u4e00\u4e2a\u975e\u7a7a\u7684\u6587\u4ef6\u5939\u4e2d\u521b\u5efagit\u4ed3\u5e93,\u4f46\u6bcf\u6b21\u90fd\u662f\u81ea\u5df1\u641e\u4e86\u4e2a\u7a7a\u7684\u6587\u4ef6\u5939\u53bb\u521b\u5efag &hellip; <a href=\"https:\/\/www.caiqinyi.cn\/index.php\/2020\/01\/13\/git_existing_folder\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u5728\u975e\u7a7a\u7684\u6587\u4ef6\u5939\u4e2d\u521b\u5efagit\u4ed3\u5e93<\/span><\/a><\/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":[],"_links":{"self":[{"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/posts\/471"}],"collection":[{"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/comments?post=471"}],"version-history":[{"count":8,"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/posts\/471\/revisions"}],"predecessor-version":[{"id":476,"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/posts\/471\/revisions\/476"}],"wp:attachment":[{"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/media?parent=471"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/categories?post=471"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/tags?post=471"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}