{"id":145,"date":"2023-05-16T10:16:24","date_gmt":"2023-05-16T02:16:24","guid":{"rendered":"https:\/\/boostup.cf\/?p=145"},"modified":"2024-08-25T17:13:44","modified_gmt":"2024-08-25T09:13:44","slug":"git%e5%91%bd%e4%bb%a4","status":"publish","type":"post","link":"https:\/\/189505.xyz\/?p=145","title":{"rendered":"git\u547d\u4ee4"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_40 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" area-label=\"ez-toc-toggle-icon-1\"><label for=\"item-6a1caa0b748d1\" aria-label=\"Table of Content\"><span style=\"display: flex;align-items: center;width: 35px;height: 30px;justify-content: center;direction:ltr;\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/label><input  type=\"checkbox\" id=\"item-6a1caa0b748d1\"><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/189505.xyz\/?p=145\/#git_diff_side_by_side\" title=\"\ngit diff side by side \n\">\ngit diff side by side \n<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/189505.xyz\/?p=145\/#submodule\" title=\"\nsubmodule \n\">\nsubmodule \n<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/189505.xyz\/?p=145\/#copy_file_while_preserve_history\" title=\"\ncopy file while preserve history \n\">\ncopy file while preserve history \n<\/a><\/li><\/ul><\/nav><\/div>\n<h1><span class=\"ez-toc-section\" id=\"git_diff_side_by_side\"><\/span>\ngit diff side by side<br \/>\n<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<p><a href=\"https:\/\/stackoverflow.com\/questions\/7669963\/how-can-i-get-a-side-by-side-diff-when-i-do-git-diff\">https:\/\/stackoverflow.com\/questions\/7669963\/how-can-i-get-a-side-by-side-diff-when-i-do-git-diff<\/a><br \/>\ngit difftool -y<\/p>\n<h1><span class=\"ez-toc-section\" id=\"submodule\"><\/span>\nsubmodule<br \/>\n<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<p>clone with submodule<br \/>\nWith version 2.13 of Git and later, --recurse-submodules can be used instead of --recursive:<\/p>\n<pre><code>git clone --recurse-submodules -j8 git:\/\/github.com\/foo\/bar.git\ncd bar<\/code><\/pre>\n<p>Editor\u2019s note: -j8 is an optional performance optimization that became available in version 2.8, and fetches up to 8 submodules at a time in parallel \u2014 see man git-clone.<\/p>\n<p>With version 1.9 of Git up until version 2.12 (-j flag only available in version 2.8+):<\/p>\n<pre><code>git clone --recursive -j8 git:\/\/github.com\/foo\/bar.git\ncd bar<\/code><\/pre>\n<p>With version 1.6.5 of Git and later, you can use:<\/p>\n<pre><code>git clone --recursive git:\/\/github.com\/foo\/bar.git\ncd bar<\/code><\/pre>\n<p>For already cloned repos, or older Git versions, use:<\/p>\n<pre><code>git clone git:\/\/github.com\/foo\/bar.git\ncd bar\ngit submodule update --init --recursive<\/code><\/pre>\n<h1><span class=\"ez-toc-section\" id=\"copy_file_while_preserve_history\"><\/span>\ncopy file while preserve history<br \/>\n<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<p>\nAll you have to do is:\n<\/p>\n<ol>\n<li>\nmove the file to two different locations,\n<\/li>\n<li>\nmerge the two commits that do the above, and\n<\/li>\n<li>\nmove one copy back to the original location.\n<\/li>\n<\/ol>\n<p>\nYou will be able to see historical attributions (using git blame) and full history of changes (using git log) for both files.\n<\/p>\n<p>\nSuppose you want to create a copy of file foo called bar. In that case the workflow you'd use would look like this:\n<\/p>\n<pre><code>git mv foo bar\ngit commit\n\nSAVED=`git rev-parse HEAD`\ngit reset --hard HEAD^\ngit mv foo copy\ngit commit\n\ngit merge $SAVED     # This will generate conflicts\ngit commit -a        # Trivially resolved like this\n\ngit mv copy foo\ngit commit<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>git diff side by side https:\/\/stackoverflow.com\/questio &#8230; <a title=\"git\u547d\u4ee4\" class=\"read-more\" href=\"https:\/\/189505.xyz\/?p=145\" aria-label=\"More on git\u547d\u4ee4\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"_links":{"self":[{"href":"https:\/\/189505.xyz\/index.php?rest_route=\/wp\/v2\/posts\/145"}],"collection":[{"href":"https:\/\/189505.xyz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/189505.xyz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/189505.xyz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/189505.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=145"}],"version-history":[{"count":6,"href":"https:\/\/189505.xyz\/index.php?rest_route=\/wp\/v2\/posts\/145\/revisions"}],"predecessor-version":[{"id":466,"href":"https:\/\/189505.xyz\/index.php?rest_route=\/wp\/v2\/posts\/145\/revisions\/466"}],"wp:attachment":[{"href":"https:\/\/189505.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=145"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/189505.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=145"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/189505.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=145"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}