{"id":4588,"date":"2020-09-17T16:30:43","date_gmt":"2020-09-17T17:00:43","guid":{"rendered":"https:\/\/ultering.com\/it4us\/?p=4588"},"modified":"2020-09-20T14:06:31","modified_gmt":"2020-09-20T14:36:31","slug":"git-using-git-to-sync-vscode-workspaces-or-whatever","status":"publish","type":"post","link":"https:\/\/ultering.com\/it4us\/?p=4588","title":{"rendered":"GIT: Using Git to Sync Workspaces for VSCode,  Eclipse or Whatever"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_73 counter-hierarchy ez-toc-counter ez-toc-white ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69f41f546e313\" class=\"ez-toc-cssicon-toggle-label\"><span class><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" 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\" \/><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" 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><\/span><\/label><input type=\"checkbox\" id=\"ez-toc-cssicon-toggle-item-69f41f546e313\" checked aria-label=\"Toggle\"><nav><ul class=\"ez-toc-list ez-toc-list-level-1 \"><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/ultering.com\/it4us\/?p=4588\/#Motivation_%E2%80%93_Why_Should_I_think_about_this\" title=\"Motivation &#8211; Why Should I think about this?\">Motivation &#8211; Why Should I think about this?<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/ultering.com\/it4us\/?p=4588\/#How_To\" title=\"How To\">How To<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/ultering.com\/it4us\/?p=4588\/#The_Trick_the_%E2%80%9Cforward_administration_approach%E2%80%9D\" title=\"The Trick: the &#8220;forward administration approach&#8221;\">The Trick: the &#8220;forward administration approach&#8221;<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/ultering.com\/it4us\/?p=4588\/#Note\" title=\"Note\">Note<\/a><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Motivation_%E2%80%93_Why_Should_I_think_about_this\"><\/span>Motivation &#8211; Why Should I think about this?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><em>This article assumes that you have skill to work with Git.<\/em><br>\n<em>Its purpose is not a Git&#8217;s tutorial but a direction for an another usage for versioning control.<\/em><\/p>\n<p>Every developer uses to customize the workspaces of Eclipse, VSCode, etc.<br>\nAs much as you work, more customized it gets.<br>\nVery painful and time-consuming when we need to switch machines or even work on a different one.<br>\nUnless you register all extensions(VSCode), plugins(Eclipse) in a document to make sure that you&#8217;ll be able to recover or original configuration, you&#8217;ll depend upon memory, that is not reliable, because most of the time are numerous and we don&#8217;t handle them daily, so very probably the configuration is lost or partially recovered.<\/p>\n<p>There is an alternative using Git, or another versioning control.<br>\nIt is simple, fast and you no more is required to take note of your configurations.<\/p>\n<p>&nbsp;<\/p>\n<h2><span class=\"ez-toc-section\" id=\"How_To\"><\/span>How To<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The example will be shown using VSCode, but the same apply for any other workspace that has an external path (not internal to the software).<\/p>\n<p>VSCode, by default, saves your configuration here:<\/p>\n<p>C:\\Users\\<em>yourLogin<\/em>\\.vscode<\/p>\n<p>Create a local git repository here.<\/p>\n<p>C:\\Users\\<em>yourLogin<\/em>\\.vscode\\.git<\/p>\n<p>Also attach to a remote repository.<br>\nAn alternative is GiHub, using the private mode.<\/p>\n<h2><\/h2>\n<h2><span class=\"ez-toc-section\" id=\"The_Trick_the_%E2%80%9Cforward_administration_approach%E2%80%9D\"><\/span>The Trick: the &#8220;forward administration approach&#8221;<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>If you try to use git as usual, it will not work.<br>\nYou&#8217;ll get mad with the conflicts when merge is done.<br>\nIt doesn&#8217;t work.<br>\nThe tip and trick is to use a &#8220;forward administration approach&#8221;.<\/p>\n<p>How does it work?<br>\nRule of thumb, you&#8217;ll never ever merge.<br>\nDue to this golden rule, you&#8217;ll never perform changes in more than one environment at the same time.<br>\nIt is easy since it is personal stuff, therefore there is just one user: yourself.<\/p>\n<p>The strategy follows below:<\/p>\n<ol>\n<li>Elect an environment as the current reference.<\/li>\n<li>Create a new branch from the current reference each time you need to get a copy to begin working on a new environment.<\/li>\n<li>If you don&#8217;t install things, the current reference remains the same.<\/li>\n<li>If you have changed the common configuration (not local) or installed a new extension, the current environment becomes the reference.<\/li>\n<li>When you switch machines or environment, create a new branch from the last current environment.<\/li>\n<li>Delete old local and remote old branches to save disk space.<\/li>\n<li>If something goes wrong, you have prior branches that may restore a previous state and you don&#8217;t loose everything, just the last things since the commit for that branche.<\/li>\n<\/ol>\n<p>This is how I create my branches.<br>\nThe &#8220;n6w10&#8221; is the hostname of a machine, so it is n7w10.<br>\nI use date by hostname. Easier to track.<\/p>\n<p><noscript><img decoding=\"async\" src=\"https:\/\/ultering.com\/it4us\/wp-content\/uploads\/2020\/09\/git_sync_workspaces_01.jpg\" alt width=\"334\" height=\"217\"><\/noscript><img decoding=\"async\" src=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20334%20217%22%3E%3C%2Fsvg%3E\" alt width=\"334\" height=\"217\" data-src=\"https:\/\/ultering.com\/it4us\/wp-content\/uploads\/2020\/09\/git_sync_workspaces_01.jpg\" class=\" lazyload\"><\/p>\n<p>&nbsp;<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Note\"><\/span>Note<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Take care when using console commands via cmd.exe.<br>\nSometimes, depending on your machine configuration, if having administrator status, may cause some malfunction like when you issue the command &#8220;git branch -r&#8221;, comes nothing.<br>\nIf you use scripts, sometimes it may loose the session and the registry ssh file, so when you do a push keeps asking to accept encryption key. No problem, accept it and it will work fine, or open a new prompt.<\/p>\n<p>Such issues are not deterrent.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<!--CusAds0-->\n<div style=\"font-size: 0px; height: 0px; line-height: 0px; margin: 0; padding: 0; clear: both;\"><\/div>","protected":false},"excerpt":{"rendered":"<p>Motivation &#8211; Why Should I think about this? This article assumes that you have skill to work with Git. Its purpose is not a Git&#8217;s tutorial but a direction for an another usage for versioning control. Every developer uses to customize the workspaces of Eclipse, VSCode, etc. As much as you work, more customized it &#8230; <a href=\"https:\/\/ultering.com\/it4us\/?p=4588\" class=\"more-link\">Read More<span class=\"screen-reader-text\"> &#8220;GIT: Using Git to Sync Workspaces for VSCode,  Eclipse or Whatever&#8221;<\/span> &raquo;<\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"categories":[156,35],"tags":[],"class_list":["post-4588","post","type-post","status-publish","format-standard","hentry","category-soft","category-versioning"],"_links":{"self":[{"href":"https:\/\/ultering.com\/it4us\/index.php?rest_route=\/wp\/v2\/posts\/4588","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ultering.com\/it4us\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ultering.com\/it4us\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ultering.com\/it4us\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/ultering.com\/it4us\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4588"}],"version-history":[{"count":4,"href":"https:\/\/ultering.com\/it4us\/index.php?rest_route=\/wp\/v2\/posts\/4588\/revisions"}],"predecessor-version":[{"id":4619,"href":"https:\/\/ultering.com\/it4us\/index.php?rest_route=\/wp\/v2\/posts\/4588\/revisions\/4619"}],"wp:attachment":[{"href":"https:\/\/ultering.com\/it4us\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4588"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ultering.com\/it4us\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4588"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ultering.com\/it4us\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4588"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}