{"id":6222,"date":"2020-05-02T15:45:37","date_gmt":"2020-05-02T15:45:37","guid":{"rendered":"https:\/\/max-drake.cc\/?p=6222"},"modified":"2020-05-02T15:46:03","modified_gmt":"2020-05-02T15:46:03","slug":"github-revisited","status":"publish","type":"post","link":"https:\/\/max-drake.cc\/?p=6222","title":{"rendered":"Github revisited"},"content":{"rendered":"\n<p>I&#8217;m looking at trying to host a node.js instance on something like<strong><a rel=\"noreferrer noopener\" href=\"https:\/\/heroku.com\" target=\"_blank\"> Heroku<\/a><\/strong> and for pushing to Heroku I saw in the Code Train videos on deploying node that Daniel was using git commands to push the info across to Heroku.<\/p>\n\n\n\n<p>Another reason is that I&#8217;m sometimes working in the bedroom, sometimes in the living room, and in the past I&#8217;ve been using MyCloud to transfer files between the two. <\/p>\n\n\n\n<p>A third reason is that I can fill up their server with my code so I don&#8217;t need to save it on my PC. Not an issue with my main laptop but the Surface 3 disk space is struggling. <\/p>\n\n\n\n<p>A fourth reason is versioning and branches. Watching some of the tutorials I see there are several parts to the coding and it changes, so ity would be good to have branches of the code kept at earlier stages that I could go back to if I wanted. <\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Install &amp; VS Code<\/h4>\n\n\n\n<p>I did initially have a couple of issues with this as although I have a github account from before,. I&#8217;ve changed the main PC so need to install git on that. <\/p>\n\n\n\n<p>Also I&#8217;m now using VS code, for 2 reasons mainly, 1\/ It allows you to run a local server and that will update as soon as you save your altered code in VS Code. 2\/ It has an inbuilt terminal, so you do not have to have a coding editor open and also a Command Prompt window too, its all in the same programme. That is handy for the git commands as they work in the terminal. A pparently there is a desktop programme but most people use the command line. There are also a few plugings for Git in VS Code. I loaded one but am unsure what it does. Still it works, so thats the main issue. <\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Code Train playlist for Github <\/h4>\n\n\n\n<p>I&#8217;ve been looking at these, but jumping around between them. Mainly focussing on vids 6 &amp; 7 in the series<\/p>\n\n\n\n<figure class=\"wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe title=\"Git and GitHub for Poets\" width=\"678\" height=\"381\" data-src=\"https:\/\/www.youtube.com\/embed\/videoseries?list=PLRqwX-V7Uu6ZF9C0YMKuns9sLDzK6zoiV\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" data-load-mode=\"1\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">Process 1 Creating repository in Github then cloning on PC<\/h4>\n\n\n\n<p>This is video 6 in the series. You create a repository in Giithub then you go to your PC an, in the terminal go<strong> > git clone <\/strong> <strong>https:\/\/github.com\/drakemax\/JasonServer.git <\/strong>(you give it the url of the github repository.<\/p>\n\n\n\n<p>When making the repository you need to tick the  <strong>Initialize this repository with a README<\/strong>. <\/p>\n\n\n\n<p>After you&#8217;ve cloned the directory, if you have a folder with all your code in, you have to copy\/move it across to that new directory- note, I dont think it can be the same name as the original. You also need to go one folder up and create a file with any name in VS Code so that you can open terminal and write the git commands. <\/p>\n\n\n\n<p>Not an elegant method as my workflow is 1\/ I write code, then think about sharing it. So  creating a repository on PC first seems to work better for me.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Process 2. Git init on your PC then create repository in Github <\/h4>\n\n\n\n<p>I started doing this method and got all confused. I banjaxed it and got all confused. <\/p>\n\n\n\n<p>You make the initial <strong><span style=\"color:#cf2e2e\" class=\"color\">>git init<\/span><\/strong> in your selected directory<\/p>\n\n\n\n<p> then go across to Github and create the repository, now you can cut\/paste the folder name so they are the same name.<\/p>\n\n\n\n<p>Then get the link to the repository and in terminal >git remote origin  https:\/\/github.com\/drakemax\/JasonServer.git and give it the URL to the repository. <\/p>\n\n\n\n<p>You do have to make the README.md file on the folder on your PC, but they tell you the code when you make the repository so you just cut\/paste the code into the terminal to build it all. See vid below and go to near the end for connection to remote <\/p>\n\n\n\n<figure class=\"wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe title=\"1.7: git init and git add - Git and GitHub for Poets\" width=\"678\" height=\"381\" data-src=\"https:\/\/www.youtube.com\/embed\/9p2d-CuVlgc?list=PLRqwX-V7Uu6ZF9C0YMKuns9sLDzK6zoiV\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" data-load-mode=\"1\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>So, go to the folder where the code is:<strong> > .git init<\/strong><\/p>\n\n\n\n<p>Then <strong>> git add . <\/strong><\/p>\n\n\n\n<p><em>If you don&#8217;t do the add . it sees the repository on your PC as empty of files.<\/em> Make sure you do it before running the code below, or you have to do the git commit and thn git push again<\/p>\n\n\n\n<p>Then &#8211; Copy name of folder to clipboard, go to Github in the browser and make new repository and paste name of folder in there. <\/p>\n\n\n\n<p>Make sure you do not click Init README.md and create. <\/p>\n\n\n\n<p>The code pops up:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo \"# Webscrape\" >> README.md\ngit init\ngit add README.md\ngit commit -m \"first commit\"\ngit remote add origin https:\/\/github.com\/drakemax\/Webscrape.git\ngit push -u origin master<\/code><\/pre>\n\n\n\n<p>cut\/paste this into the terminal and run, if it didn&#8217;t go, then > git push <\/p>\n\n\n\n<p>Then go to Github and refresh and see if its there.<\/p>\n\n\n\n<p> You may want to add info to README.md file. <\/p>\n\n\n\n<p>And you have a filled Github repository of your initial code. <\/p>\n\n\n\n<p>Updating later, in a folder that is a git repository on your PC:<\/p>\n\n\n\n<p><strong><span style=\"color:#cf2e2e\" class=\"color\">>git add . <\/span><\/strong>(or name specific files that you want to update\/add to repository)<\/p>\n\n\n\n<p><strong>><span style=\"color:#cf2e2e\" class=\"color\"> git commit -m &#8220;<em>some message to identify an updated version here<\/em>&#8220;<\/span><\/strong><\/p>\n\n\n\n<p><strong><span style=\"color:#cf2e2e\" class=\"color\">>git push<\/span><\/strong><\/p>\n\n\n\n<p>and it&#8217;ll push the updated code to the Github repository.<\/p>\n\n\n\n<p>If you are <strong>cloning a repository on another computer<\/strong> then:<\/p>\n\n\n\n<p><strong><span style=\"color:#cf2e2e\" class=\"color\">>git clone {URL pastyed of git repository}<\/span><\/strong><\/p>\n\n\n\n<p>If you are updating a repository on your PC and latest code is in Github then go to directory:<\/p>\n\n\n\n<p><strong><span style=\"color:#cf2e2e\" class=\"color\">>git pull<\/span><\/strong><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Private folders<\/h4>\n\n\n\n<p>For free accounts, when I first looked at Github they had to be public. I was always a bit awkward about this as my coding is scruffy and terrible, especially with the brevity of developers.  <\/p>\n\n\n\n<p>Now free accounts can have private repositories an as many as you like, apart from the fact that you can collaborate with only 2 (3?)others, otherwise you have to have a paid account. Thats fine as I code on my own. <\/p>\n\n\n\n\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m looking at trying to host a node.js instance on something like Heroku and for pushing to Heroku I saw in the Code Train videos on deploying node that Daniel was using git commands to push the info across to Heroku. Another reason is that I&#8217;m sometimes working in the bedroom, sometimes in the living [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":6225,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[42,29],"tags":[],"class_list":["post-6222","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-productivity","category-web"],"featured_image_src":"https:\/\/max-drake.cc\/wp-content\/uploads\/2020\/05\/2020-05-03-15_19_12-drakemax_Tutorial-Selfie.jpg","featured_image_src_square":"https:\/\/max-drake.cc\/wp-content\/uploads\/2020\/05\/2020-05-03-15_19_12-drakemax_Tutorial-Selfie.jpg","author_info":{"display_name":"Max Drake","author_link":"https:\/\/max-drake.cc\/?author=1"},"_links":{"self":[{"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/posts\/6222","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6222"}],"version-history":[{"count":0,"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/posts\/6222\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/media\/6225"}],"wp:attachment":[{"href":"https:\/\/max-drake.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6222"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6222"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6222"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}